How to boost fields in solr - solr

I already have the boost determined before hand. I have a field in the solr index called boost1 . This boost field will have a value from 1 to 10 similar to google PR rank. This is the boost that should be applied to every query ran in solr. here are the fields in my index
Id
Title
Text
Boost1
The boost field should be apply to every query. I am trying to implement functionality similar to Google PR rank. Is there a way to do this using solr?

you can add the boost during query e.g.
q={!boost b=boost1}
How_can_I_boost_the_score_of_newer_documents
However, this may need to be added explicitly by you.
If you are using dismax or edismax with the request handler, The bf (Boost Functions) parameter could be used to boost the documents.
http://wiki.apache.org/solr/DisMaxQParserPlugin#bf_.28Boost_Functions.29
bf=boost1^0.5
This can be added to defaults with the request handler definition, so that they are applied to all the search queries.
you can use function queries to vary the amount of boost FunctionQuery

I think you need to use index time document boosts. See this if you are indexing XML or this if using DataImportHandler.

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).

How to boost a solr document at query time based on attribute value

I want boost at query time all documents that have value user_id=2. Basically I want on the top of my results all the documents belonged to a specific user.
After looking at some Solr resources I ended up writing a query like, but it is not working properly.
/solr/public-main/select?q={!boost b=if(div(155623,user_id),2,1)}sometext&wt=json&indent=true&debugQuery=true
Any hints?
Thanks
You don't need to use the boost with a dynamic boost. Apply a boost query which will boost all the documents that match the query: bq=user_id:2^4. Adjust 4 to a suitable boost value depending on the rest of your boosts (if any in q or qf).
One option is to have a function query with fl=x,y,userexists:exists(query({!v='user_id:2'})) and then u can sort by userexists and then by score field.

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

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.

What is the proper way to boost items with newer dates?

I have a more like this query which I would like to update to return newer documents first. According to the documentation, I would need to add recip(ms(NOW,mydatefield),3.16e-11,1,1) to my query.
But when I try to add it to either of mlt.qf or bf parameters. The results stay exactly the same.
This is my query:
/solr/mlt?
q=id:cms.article.137861
&defType=edismax
&rows=3
&indent=on
&mlt.fl=series_id,tags,title,text
&mlt.qf=show_id text^1.1 title^1.1 tags^90
&wt=json
&fl=url,title,tags,django_id,content_type_id
&bf=recip(ms(NOW,pub_date),3.16e-11,1,1)
this is taken from the solr wiki (its down but i have it cached)
i think this is what you are looking for.
How can I boost the score of newer documents
Do an explicit sort by date (relevancy scores are ignored)
Use an index-time boost that is larger for newer documents
Use a FunctionQuery to influence the score based on a date field.
In Solr 1.3, use something of the form recip(rord(myfield),1,1000,1000)
In Solr 1.4, use something of the form recip(ms(NOW,mydatefield),3.16e-11,1,1)
http://lucene.apache.org/solr/api/org/apache/solr/search/function/ReciprocalFloatFunction.html http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlugin.html
A full example of a query for "ipod" with the score boosted higher the newer the product is:
http://localhost:8983/solr/select?q={!boost b=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)}ipod
One can simplify the implementation by decomposing the query into multiple arguments:
http://localhost:8983/solr/select?q={!boost b=$dateboost v=$qq}&dateboost=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)&qq=ipod
Now the main "q" argument as well as the "dateboost" argument may be specified as defaults in a search handler in solrconfig.xml, and clients would only need to pass "qq", the user query.
To boost another query type such as a dismax query, the value of the boost query is a full sub-query and hence can use the {!querytype} syntax. Alternately, the defType param can be used in the boost local params to set the default type to dismax. The other dismax parameters may be set as top level parameters.
http://localhost:8983/solr/select?q={!boost b=$dateboost v=$qq defType=dismax}&dateboost=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)&qf=text&pf=text&qq=ipod
Consider using reduced precision to prevent excessive memory consumption. You would instead use recip(ms(NOW/HOUR,mydatefield),3.16e-11,1,1). See this thread for more information.
apparently your date field is not a TrieDate

Resources