Relevancy boosting

Let's see how we can boost some documents in Solr. Relevancy boosting can be very helpful in e-commerce websites to promote some products. In our musicStore core, we've specified a Boolean field called sale, which will tell whether the song is available for sale or not. While showing the results to the user, we can boost the documents that have sale=true in them.

We'll need to index the sampleMusicStoreData2.csvfile to Solr, as it contains more data about songs, which is needed for this example. We can use the following command to index the file:

curl 'http://localhost:8983/solr/musicStore/update?commit=true' --data-binary @sampleMusicStoreData2.csv -H 'Content-type:application/csv'

We can now use the following URL to see the indexed documents that are available for sale and whose artistName matches Rihanna:

http://localhost:8983/solr/musicStore/select?q={!boost%20b=sale}artistName:Rihanna&wt=json&indent=true&fl=id,songName,sale&rows=100

Relevancy boosting

From the preceding output, we can see that it returns those documents whose sale field is set to true first, and then it returns those documents whose sale field is set to false.

Note

More information about boosting of documents can be found at https://wiki.apache.org/solr/SolrRelevancyFAQ.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.204.201