Search code examples
solrnopcommercesolrnet

implement low relevancy to Out-of-Stock products while searching


I have indexed stockAvailability field in solr schema for product & if product is not in stock then this stockAvailability field contains false. otherwise it contains true.

I am using solr to search products and when I search product, I want out of stock products at the end of search result from solr.

What will be the query for this feature..?


Solution

  • Depending on which query parser you're using, you can apply a large boost to any documents that match your boost query:

    &bq=inStock:true^999
    

    This will apply an extra boost to any documents about products that are in stock. Adjust 999 to something suitable for your other boost values.

    If you need a more general way (for certain words, etc.), have a look at the Solr Relevancy Faq of how to apply a boost to any documents that doesn't contain a term.