I'm trying to determine how to sort or score the results of my query so that documents with an explicit match on a particular field will be returned first, followed by other matching documents in ascending distance.
Following the examples used in Solr's Spatial tutorials, let's say that I have a couple Stores, which looks something like this (pseudo):
<Store>
<Id>1</Id>
<Coords>10,-15</Coords>
<PostalCode>12345</PostalCode>
<ServiceArea>
<PostalCode>12345</PostalCode>
<PostalCode>23456</PostalCode>
</ServiceArea>
</Store>
<Store>
<Id>2</Id>
<Coords>11,-16</Coords>
<PostalCode>23456</PostalCode>
<ServiceArea>
<PostalCode>12345</PostalCode>
<PostalCode>23456</PostalCode>
</ServiceArea>
</Store>
So, two stores. Each in their own postal codes, and each servicing each other's postal codes. Now I want to query something to the effect of:
Find stores which service PostalCode 12345
Ordered by stores in PostalCode 12345 first
Then ordered by ascending distance from PostalCode 12345
I'm trying to keep this to using the StandardQueryParser
, and if boosting is involved it needs to be defined in the query, rather than the index.