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
From the preceding...