Hi,

I am trying to solve a sorting problem using Solr. The sorting requirements are 
a bit complicated.
I have to sort the documents by three different criteria:

- First by number of keywords that match  (coordination factor)
- Then, within the documents that match the same number of keywords, sort first 
the documents that match a user value (country) and then the rest.
- Then within those two blocks, sort by a document value (popularity).

I have managed to make the second and third criteria to work, with a query like 
this:

http://localhost:8983/solr/select/?q=description%3Afootball&version=2.2&start=0&rows=10&indent=on&qq=country_uk:true&sort=map%28query%28$qq,-1%29,0,9999999,1%29%20desc,popularity%20desc

This gets with the query function a positive value for the documents that match 
the country, and a negative for the ones that don't, and then maps those ones 
to 1, so I have two blocks of documents with sorting value of 1 and -1, which 
works for me cause ties are then sorted by popularity.  But as you see, this is 
only searching for 1 keyword.

My problem comes with the first requirement when we search for more than one 
keyword, because as I understand, I would like to sort by the coordination 
factor, which is the number of query keywords that each document matches. The 
problem is that there's no Function Query I can use to get that value, so I 
don't know how to proceed. I was trying to understand if there was a way to 
split the regular score into sets which should mean that the same number of 
keywords was matched, but the score depends on different things, and the range 
of values can be arbitrary, so I'm not able to make such a function.

Is there any solution to this?

Thanks,

Jesus.

Reply via email to