How to calculate score of a doc in solr? - solr

I have a solr core named Search Stats with fields
query
search_count
number_of_clicks
added_to_cart
order_placed
I want a scoring function so that I can boost the docs according to the data.
This data is actually want to use for showing suggestions.
I have already used the sort function. suggest me some boost function other than sorting.

you can specify the same in Solr that you want to retrieve the score of every document using q=colour Plus&fl=*,score
Read more on this in below link
http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_see_the_relevancy_scores_for_search_results
Lucene/Solr, provides TF-IDF (VSM based) scoring strategy.
The below link highlights more about TF and other terms
http://www.solrtutorial.com/solr-search-relevancy.html

There are three boost methods you can use: boost, bf, and bq. Nicely laid out here. The boost function can be used generally, and the bf and bq are specific to edismax and dismax. See the solr wiki here and here. There are also index-time boosts, as described in the first wiki link above.

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

Tweaking Solr scoring function

In Solr 6.0.0, I want to tweak the scoring based on which field matches (in indexing and searching xml files), do I have to override my own similarity class ?
Although you can use a custom Similarity, that's more useful for changing things like how term popularity effects score. Simply ranking different fields differently is typically what you use score boosts for.
q=foo:something^100 OR bar:something^10
I recommend reading https://wiki.apache.org/solr/SolrRelevancyFAQ and maybe take a look at the dismax query parser, which has a convenient notation for that kind of thing. See https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser (and the "qf" parameter)

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 to boost fields in 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.

Use different Solr Similarity algo for every search

Is possible in Solr 1.4 to specify which similarity class to use for every search within a single index?
Let's say, I got 2 type of search (keyword and brand). For keyword search, I want to use the DefaultSimilarity class. But, for brand search, I want to use my CustomSimilarity class.
I've been modifying the schema.xml to specify a single similarity class to use. But, I came to this requirement that I have to use 2 different similarity classes.
I'll be glad to here your thoughts on this.
Thanks in advance.
AFAIK the Similarity can only be defined at the schema/index level and can't be overriden per fieldType or per query. (see this and this).
However you can customize your result ordering using other methods: boosting, function queries, a custom analyzer per field, or even sorting.
The Solr Relevancy Cookbook wiki is a good reference.

Resources