Hi,

In an online bookstore project I'm working on, most frontend widgets are search 
driven. Most often they query with some filters and a sort order, such as 
availabledate desc or simply by score.

However, to allow editorial control, some widgets will display a fixed list of 
books, defined as an ordered list of ISBN numbers inserted by the editor. Based 
on this we do a Solr search to fetch the data to display: 
&fq=isbn:(9788200011699 OR 9788200012658 OR ...)

It is important to return the results in the same order as the explicitly given 
list of ISBNs. But I cannot see a way to do that, not even with sort by 
function. So currently we re-order the result list in the frontend.

Would it make sense with an "explicit" sort order, perhaps implemented as a 
function?

&sort=fieldvaluelist(isbn,1000,1,0,$isbnorder) desc, price 
asc&isbnorder=9788200011699,9788200012658,9788200013839,9788200014140

The function would be defined as
  
fieldvaluelist(<field>,<startvalue>,<gap>,<fallback>,<field-value>[,<field-value>...])
The output of the example above would be:
  For document with ISBN=9788200011699: 1000
  For document with ISBN=9788200012658: 999
  For document with ISBN=9788200013839: 998
  For document with ISBN not in the list: 0 (fallback - in which case the 
second sort order would kick in)

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

Reply via email to