Solr Boost on non-query term - solr

All my results are of type "active, inactive, historical" - this is a field indexed by Solr.
I want my results to be returned with a boost to type="active".
I could do ordering which will suffice, but its not great.
So, when a user searches for a term "sick", they get the most relevant results to sick, but with a higher boost for documents where its active.
Not just a sorted result set!

You can use the edismax parser and the following boost query bq paramter to get your desired results to be boosted to the top...
http://localhost:8983/solr/select/?q=sick&defType=edismax&bq=type:active^5.0
In this example you are adding a boost query to increase the relevancy of documents whose type is active.
Here are some more examples on the Solr Wiki DisMaxQParserPlugin page.

The above example will create an additive boost.
If you want an multiplicative boost for "type=active" you could add:
&boost=if(termfreq(type,"active"),2,1)
Which gives a factor 2 boost for "type=active"

Related

SOLR edismax with BF function on non existing fields

I would like to apply negative boost on the documents which does not have specific fields. But its not working and results the same boost value for the document with and without that field.Any pointers would be of great help.
bf=if(not(exists('image-small_string')),0,-500)
The answer is to boost those documents that do not match your query, instead of trying to apply a negative boost to those that do.
To boost documents that has a specific field, you can use bq=foo:[* TO *]^5 (and adjust the boost factory to match the behaviour you're looking for).

Which one to use for boosting bq or q.alt

As the title says which one I need to use for boosting in solr. whether its q.alt or bq. I tried the boosting in both however I'm not clear on how the boosting is working. Because in q.alt I got the correct results when I specified boosting value as 1000 at the same time I got the same results in bq with the boosting value as 2
Can someone help me to get the best practices for boosting?
My SOLR version is 3.5.
It depends upon what are you trying to boost.
Use qf (query fields) - to boost the individual search fields which have different weightage.
for e.g. For a document title has a higher weightage then description then you would use title^2 description^1
q.alt is just an alternate query factor in case on q is specified.
Use bq and bf for boosting certain matches, ranges or when the need to apply some functions on them. These usually are the extar boost and not the part of the search boost.
for e.g. for latest documents you would boost by date, or Price range or you want to boost on sum of fields etc ...
use qf parameter for boosting
Dismax Query Parser Wiki

How can you add a formula scoring boost to a Solr "More Like This" query?

I'm doing a "More Like This" query on 3 text fields, but I'd like to also boost the results based on a numeric "views" field. In a normal query I'd add a boost term like "{!boost b=scale(sqrt(views),1,2)}" or something similar, but this doesn't seem to work if I specify it in the mlt.qf field. Is formula based boosting allowed in MLT queries?
According to the More Like This page on the Solr Wiki, the mlt.qf field allows for boosts.
Query fields and their boosts using the same format as that used in DisMaxQParserPlugin. These fields must also be specified in mlt.fl.
Checkout the syntax for boosting with the DisMaxQParserPlugin and you should be able to get the boosting you desire.
Also, check out the answer to this previous question - Is it possible to boost mlt queries in Solr

What means "document popularity" in Solr

What is document popularity in solr indexing..?
EDisMax parser uses boost parameter. In the example &boost=popularity like that I noticed one query. I couldn't understand what is boost as well as boost=popularity. Before understanding the boost parameter I'd like to know what is "popularity" in document indexing.
popularity is just "some field" which has been used as an example while boost is a query parameter defined for the edismax request handler. Boosting means to influence the scoring (the relevance of each search hit) depending on some field value (or result of some function based on field values).
See section The boost Parameter in https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser.
If you want to implement something like popularity in your own index you would have to:
add a field to your schema called popularity with type int or float or ExternalFileField (depends on how you index and apply it).
gather statistics data for your search results and store those in relation to the document IDs (e.g. by evaluating access logs)
during index time or via ExternalFileField (or in the future via docValues partial updates) store the popularity values that you get from your statistics data.
apply the boost during query time by setting the parameter boost=popularity (or using popularity in a function query).
More on popularity boosting:
https://www.slideshare.net/lucenerevolution/potter-timothy-boosting-documents-in-solr
docValues partial update:
https://issues.apache.org/jira/browse/SOLR-5944
ExternalFileField:
http://www.findwise.com/blog/externalfilefield-in-solr/
Boosting is used to increase the score of the certain documents. You can use index time boosting or query time boosting. For index time boosting you can set boost attribute and value to the document you index. For query time boosting you can either boost field by setting your boost value, or you can use predefined function queries.
For more information about boosting check documents in Solr wiki.
boost=popularity means that documents popularity is calculated in the external field (using ExternalFileField) and used to increase the score by using popularity value. Popularity of the documents can be calculated using the view count or any other parameters you want.For more about boosting documents by popularity you can check this document.

How to score high of document containing "Burj Khalifa" in title and then in summary field in SOLR

I want to sort document by relevancy i.e. First all docs having "Burj Khalifa" in title and then in summary field? and sort by publishdate as well. means latest documents must have high score.
criteria is like sort by score with publishdate
http://localhost:8080/solr/select?sort=score+desc,publishdate+desc&q=Burj Khalifa
I think you don't want sorting in this case, as it defines a strict ordering on the result set. Instead, I'd use DisMax with a FunctionQuery (see here to boost newer documents) and the qf parameter to boost the title field.
You'll have to play a bit with the boost values to get optimal results.

Resources