On Sep 27, 2007, at 2:50 PM, Chris Hostetter wrote:
to answer the broader question of using customized
LUcene SortComparatorSource objects in solr -- it is in fact possible.

In Solr, all decisisons about how to sort are driven by FieldTypes. You can subclass any of the FieldTypes that come with Solr and override just the getSortField method to use whatever sort logic you want and then use
your new FieldType as you would any other plugin...

http://wiki.apache.org/solr/SolrPlugins

In the case where you have a custom SortComparatorSource that is not
"field" specific (or uses data from morethen one field) you would need to make your field type smart enough to let you cofigure (via the <fieldType> declaration in the schema) which fields (if any) to get it's data from, and then create a marker field of that type, which you don't use to index
or store any data, but you use to indicate when to trigger your custom
sort logic, ie...


    <fieldType name="distance" class="solr.YourField"
               latFieldName="latitude" lonFieldName="longitute"
               stored="false" indexed="false />
    ...
   <field name="latitude" type="sint" indexed="true" stored="true" />
   <field name="latitude" type="sint" indexed="true" stored="true" />
   <field name="distance" type="distance" />

...and then use "sort=distance+asc" in your query

Using something like this, how would the custom SortComparatorSource get a parameter from the request to use in sorting calculations?

I haven't looked under the covers of the local-solr stuff that flew by earlier, but looks quite well done. I think I can speak for many that would love to have geo field types / sorting capability built into Solr.

        Erik

Reply via email to