solrsolr4solarium

SOLR Query with multible fields to search for


i've build a query in solr that looks like this:

https://local.solr.com/solr/select?omitHeader=true&wt=json&json.nl=flat&q=*:*&fq=xtitleLow_stringS:*1002*+OR+xartnumLow_stringS:*1002*

I want to search in solr with the query "1002" for results. I didn't work it out how to search both fields with the normal query so i used the filter query.

But i can't boost the results so im kind of lost on this point. How to build this as a query so i can boost some of the fields?

thank you.


Solution

  • You can try with the edismax handler provided by Solr. This allows to use list of fields to query. It has option to give separate weights for each of the field for scoring them differently.

    defType=edismax&q=1002&qf=xtitleLow_stringS^20 xartnumLow_stringS
    

    The above query will search for 1002 in each of the mentioned fields. It will be also adding a boost of 20x to any hits in the xtitleLow_stringS field.

    Please find the documentation link here for more details