One way to implement this is to embed a _val_ hook right after the q parameter in the HTTP query string you send to Solr. For example: http://search.buycomputers.com/select/?q=(price:[1000 TO 1500])+_val_="map(operatingsystemtype,5,5,1000)"&fl=id,name,price,details.
- Note the '+' instead of the usual '&'.
- The map function will map all values between 5 and 5 inclusive to 1000. (See here for more details.) Although this 1000 is normalized to a smaller value, it is added to the document's score. Basically, all documents with operatingsystemtype = 5 will have a very large constant added to their score, effectively pushing all these documents to the top.
- Please note that this method relies on Solr's default sort (i.e. score desc). If you provide a sort parameter, thus overriding the default order, this method won't work.
- This is called a Function Query in Solr parlance.
No comments:
Post a Comment