Search code examples
solrsolr-query-syntax

Boost Solr results if the value of an attribute is within a list or not


I have a query similar to this:

http://solr1:8983/solr/select?defType=lucenePlusSort&fl=pk_i,score&json.nl=map&qt=standard&rows=36&sort=&start=0&wt=json&q=type_s:Product+AND+is_valid_b:true

I need to boost the results where user_id_i:(123 OR 222 OR 512 OR 932)

something like => __val_:"if(user_id_i:(123 OR 222 OR 512 OR 932), 100, 0)"

But obviously I need a function that returns true or false for that particular question.


Solution

  • I think you can use the boost query parameter for this, but you will have to use the edismax query parser and not the lucenePlusSort one. (http://wiki.apache.org/solr/ExtendedDisMax#boost_.28Boost_Function.2C_multiplicative.29)

    [boost] => product(if(exists(query({!v='user_id_i:(123 OR 222 OR 512 OR 932)'})),100,1))