Markus,

A couple of code pointers for you:

* QueryComponent - this is where results are generated, it uses a SortSpec from the QParser.

* QParser#getSort - creating a custom QParser you'll be able to wire in your own custom sort

You can write your own QParserPlugin and QParser, and configure it into solrconfig.xml and should be good to go. Subclassing existing classes, this should only be a handful of lines of code to do.

        Erik


On Dec 16, 2008, at 3:54 AM, psyron wrote:


I have the same problem, also need to plugin my "customComparator", but as there is no explanation of the framework, how a RequestHandler is working,
what comes in, what comes out ... just impossible!

Can someone explain where i have to add which code, to just have the same
functionality as the StandardRequestHandler, but also adding a custom
sorting?

Thanks,
Markus


hossman wrote:


: Sort sort = new Sort(new SortField[]
:         { SortField.FIELD_SCORE, new SortField(customValue,
SortField.FLOAT,
: true) });
: indexSearcher.search(q, sort)

that appears to just be a sort on score withe a secondary reversed
float sort on whatever field name is in the variable "customValue" ...
assuming hte field name is "FIELD" that's hte same thing as...
  sort=score+asc,+FIELD+desc

: Sort sort = new Sort(new SortField(customValue, customComparator))
: indexSearcher.search(q, sort)

this is using a custom SortComparatorSource -- code you (or someone else)
has written which is not part of Lucene and which tells lucene how to
order the documents using whatever crazy logic it wants ... for obvious reasons Solr can't do that same logic (since it doesn't know what it is)

although many things in Solr are easily customizable, just by writting a
little factory and configuring it by class name, i'm afraind
SortComparatorSources aren't once of them.  You could write a custom
RequestHandler which used your SortComparatorSource, or you could write a custom FieldType that used it anything someone sorted on that field ...
but those are the best options i cna think of.



-Hoss




--
View this message in context: 
http://www.nabble.com/Custom-Sorting-tp12222659p21029370.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to