thanks a lot for the explanation. i'm a little confused about solr 1.5, especially after finding this wiki page:
http://wiki.apache.org/solr/Solr1.5 Is there a stable build available for version 1.5, so i can test your suggestion using functionquery? -robert On Nov 24, 2010, at 1:53 PM, Geert-Jan Brits wrote: > You could do it with sorting on a functionquery (which is supported from > solr 1.5) > http://wiki.apache.org/solr/FunctionQuery#Sort_By_Function > <http://wiki.apache.org/solr/FunctionQuery#Sort_By_Function> > Consider the search: > http://localhost:8093/solr/select?author:'j.k.rowling' > > sorting like you specified would involve: > > 1. introducing an extra field: 'author_exact' of type 'string' which takes > care of the exact matching. (You can populate it by defining it as a > copyfield of Author so your indexing-code doesn't change) > 2. set sortMissingLast="true" for 'num_copies' and 'num_comments' > like: <fieldType > name="num_copies" sorMissingLast="true".... > > > this makes sure that documents which don't have the value set end up at the > end of the sort when sorted on that particular field. > > 3. construct a functionquery that scores either 0 (no match) or x (not sure > what x is (1?) , but it should always be the same for all exact matches ) > > This gives > > http://localhost:8093/solr/select?author:'j.k.rowling'&sort=query({!dismaxqf=author_exact > v='j.k.rowling'}) desc > > which scores all exact matches before all partial matches. > > 4. now just concatenate the other sorts giving: > > http://localhost:8093/solr/select?author:'j.k.rowling'&sort=query({!dismaxqf=author_exact > v='j.k.rowling'}) desc, num_copies desc, num_comments desc > > That should do it. > > Please note that 'num_copies' and 'num_comments' still kick in to break the > tie for documents that exactly match on 'author_exact'. I assume this is > ok. > > I can't see a way to do it without functionqueries at the moment, which > doesn't mean there isn't any. > > Hope that helps, > > Geert-Jan > > > > > > > > *query({!dismax qf=text v='solr rocks'})* > * > * > > > > > 2010/11/24 Robert Gründler <rob...@dubture.com> > >> Hi, >> >> we have a requirement for one of our search results which has a quite >> complex sorting strategy. Let me explain the document first, using an >> example: >> >> The document is a book. It has several indexed text fields: Title, Author, >> Distributor. It has two integer columns, where one reflects the number of >> sold copies (num_copies), and the other reflects >> the number of comments on the website (num_comments). >> >> The Requirement for the relevancy looks like this: >> >> * Documents which have exact matches in the "Author" field, should be >> ranked highest, disregarding their values in "num_copies" and "num_comments" >> fields >> * After the exact matches, the sorting should be based on the value in the >> field "num_copies", but only for documents, where this field is set >> * After the num_copies matches, the sorting should be based on >> "num_comments" >> >> I'm wondering is this kind of sort order can be implemented in a single >> query, or if i need to break it down into several queries and merge the >> results on application level. >> >> -robert >> >> >>