SOLR boost query with contain syntax - solr

in my solr call i want to boost all queries that have the word "mobile" in the longtext.
My call looks like this:
&q=*my_query*&defType=edismax&qf=xtitleLow_stringS^20++xartnumLow_stringS&ps=2&bq=xtitleLow_stringS:(*mobile*)^40
when i use the Boost query like this:
&bq=xtitleLow_stringS:"mobile"^40
it will work for fulltext but i just want to boost a query that contains it. I thought i can use the "*" contain to especially search for it. But it doesen't work, is there a mistake in my syntax?
thank you!

The syntax of the boost query seems incorrect in my opinion.
The "*" wildcard can only be used in a query when preceded by the word "text".
e.g. &bq=xtitleLow_stringS:text:mobile^40
To boost all queries that contain the word "mobile", you can write as:
&bq=xtitleLow_stringS:mobile^40
This should boost any query that contains the word "mobile" in the xtitleLow_stringS field by 40 factor.

Related

Solr 3.6.2 spellcheck multi-word phrase: how to get collations without ignored stopwords?

I'm having a problem with the Solr 3.6.2 default (field based) spellchecker configured with query time parameters
spellcheck.onlyMorePopular=true
spellcheck.count=5
spellcheck.collate=true
spellcheck.maxCollations=5
spellcheck.maxCollationTries=5
on a field type which has a solr.StopFilterFactory filter on its analyzers.
The suggestion phase works as intended :
the indexed field does not contain any stopword
no suggestion is provided for a given stopword
But the resulting collation always contains the ignored stopwords, which I don't want: I'd prefer a raw suggestion of combined terms over something which looks like a "sort of" natural language answer.
For instance, searching for "handfum of perries", I'd prefer "handful berry" over "handful of berry".
I don't think that the stopwords excluded from spellchecking suggestions because of the field query analyzer are "marked" for preservation like the official documentation goes about other query elements :
Note that the non-spellcheckable terms such as those for range
queries, prefix queries etc. are detected and excluded for
spellchecking. Such non-spellcheckable terms are preserved in the
collated output so that the original query can be run again, as is.
It seems two solutions would be
either having a custom query converter so the stopwords are ignored right from the start: not sure it is possible in 3.6.2
or having a custom spellchecker that would not try to find any suggestion for a stopword (or would always suggest an "empty" string), without messing up the collation process
Am I missing something ?
Regards

No matches when mixing keywords

I am trying to do a product search setup using Solr. It does return results for keywords that follow the same order in the product name. However, when the keywords are mixed up, no results are returned. I would like to get results with scores that closely match the given keywords in any order.
My question on scoring has the schema, data configuration and query. Any help will be greatly appreciated.
As long as you enter your query as a regular query, instead of using wildcards, any hits in a text_general field as you've defined should be returned.
You can use the mm parameter to adjust how many of the terms supplied that need to match from a query. I suggest using the edismax query parser, as that allows you do to more "natural" queries instead of having to add the fieldnames in the query itself:
defType=edismax&qf=catchall&q=nikon dslr
defType=edismax&qf=catchall&q=dslr nikon
should both give the same set of documents (but possibly different scores when using phrase boosts).

How to configure SOLR queries in the conf files

My requirement is simple.
I need to search with the keyword similar to SQL LIKE.
Now the search shows results for "words" rather than checking partial characters.
Ex:-
Search query: "test"
Expected results: "test%" - Which gives "test", "tested",
"testing", etc...
Actual result: "test"
I found many query suggestions for SOLR. But I need to find the exact mechanism to put that on conf xml files.
Thanks in advance.
The quick and dirty solution is to use wildcard in your search query using an asterisk (*). For example: test*
The more proper solution would be to use stemming to remove common word endings when you index and query the data. In the default schema, the text_en_splitting field type would do this for you. Just define your field as text_en_splitting.
Are you building auto-complete?
If so, use Suggester. It's part of Solr, and it does what you're talking about extremely efficiently using either a dictionary file, or a field in your index you've designated.
http://wiki.apache.org/solr/Suggester

Solr Query with LIKE Clause

I'm working with Solr and I'd like to know if it is possible to have a LIKE clause in the query. For example, I want to know all organizations with "New York" in the title. In SQL, this would be written like Name LIKE 'New York%'.
My question - how do you write a LIKE query in Solr?
I'm using the SolrNet library, if that makes a difference.
You just search for "New York", but first you need to properly configure your field's analyzer. For example you might want to start with a field type like text_general as defined in the default Solr schema. This field type will tokenize on whitespace and other common word separators, then apply a filter of stopwords, then lowercase the terms in order to make searches case-insensitive.
More information about analyzers in the Solr wiki.
If you're using solr 3.1 or newer, have a look at the Extended DisMax Query Parser, which supports wildcard queries. You can enable it using <str name="defType">edismax</str> in the request handler configuration.
Then you can use a query like title:New York* with the same behaviour as a query with like clause. The main difference between my answer and the accepted one is that you can even search for fragment of words using wildcards. For example New Yorkers would match in this case.
Unfortunately you could have problems with case-sensitive queries even if you're using a LowerCaseFilterFactory. Have a look here to know more. Most of those problems will be fixed with the solr 3.6 release since the SOLR-2438 issue has been solved.

What is the proper syntax for using wildcards with quotes in a SOLR query string?

I'm trying to structure a query string in SOLR that will search a field for a term in quotation marks, but I want it to return substring matches. As an example:
query: "his test"
should return hits where it finds "his test", "this test", "his testing", but not "test his" for example. Does this make sense? What's the right way to construct the URL to hit /solr/select/ ?
Thanks!
to accomplish your example, just turn on an english stemmer and stopword filter in your analysis chain. the stopword filter will leave a "hole" (position increment) which will be respected by phrase queries, so "his" and "this" both map to a hole.
the stemfilter will map testing and test to the same term.
Uwe says:
There is a simple Lucene-Rule: Whenever you need wildcards think about your analysis, you probably did something wrong :-)
Your query should looks in standard way, except you need wildcard in it.
If you want to add wildcard at the beginning of the term you would need ReversedWildcardFilterFactory in the schema. Check out schema example (lines: 332-346)
For more info about how Solr with wildcards work read short article: Wildcard queries and how Solr handles them

Resources