You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Gupta, Veeranjaneya" <Ve...@travelocity.com> on 2012/01/01 09:19:54 UTC

Question about SOLR custom sort order

Hi,

I use Solr 1.4 version and I have a question about SOLR sort order.
Requirement : Sort  names(e.g. : location names like Dallas(City), las vegas(City), Texas(State), India(Country), Canada(Country), etc..) based on category(e.g. : CITY, STATE, COUNTRY, etc..)
How to sort the SOLR results based on custom order?
Expected result :

1.       Dallas

2.       Las Vegas

3.       Texas

4.       Canada

5.       India

Thanks & Regards, Gupta

Re: Question about SOLR custom sort order

Posted by Andrea Gazzarini <ag...@apache.org>.
We fullfilled a similar requirement by creating a new field that is
populated at client-level (a standalone app that converts binary data
in solr input documents)

Andrea

On 1/1/12, Erick Erickson <er...@gmail.com> wrote:
> There's no good way of enforcing this as far as I know
> as you've outlined the problem. You can easily specify
> multiple sort criteria, where ties in the first criteria
> are broken by the second criteria and so on.
>
> So, if your records have *no* city value you can do what
> you want by specifying the city field to sortMissingLast
> then specifying state as your second criteria.
>
> So you can probably do what you want by breaking
> up your location field into fields that are specific
> for sorting (probably use copyfield here?) and specifying
> as above.
>
>
> Best
> Erick
>
> On Sun, Jan 1, 2012 at 3:19 AM, Gupta, Veeranjaneya
> <Ve...@travelocity.com> wrote:
>> Hi,
>>
>> I use Solr 1.4 version and I have a question about SOLR sort order.
>> Requirement : Sort  names(e.g. : location names like Dallas(City), las
>> vegas(City), Texas(State), India(Country), Canada(Country), etc..) based
>> on category(e.g. : CITY, STATE, COUNTRY, etc..)
>> How to sort the SOLR results based on custom order?
>> Expected result :
>>
>> 1.       Dallas
>>
>> 2.       Las Vegas
>>
>> 3.       Texas
>>
>> 4.       Canada
>>
>> 5.       India
>>
>> Thanks & Regards, Gupta
>

Re: Question about SOLR custom sort order

Posted by Erick Erickson <er...@gmail.com>.
There's no good way of enforcing this as far as I know
as you've outlined the problem. You can easily specify
multiple sort criteria, where ties in the first criteria
are broken by the second criteria and so on.

So, if your records have *no* city value you can do what
you want by specifying the city field to sortMissingLast
then specifying state as your second criteria.

So you can probably do what you want by breaking
up your location field into fields that are specific
for sorting (probably use copyfield here?) and specifying
as above.


Best
Erick

On Sun, Jan 1, 2012 at 3:19 AM, Gupta, Veeranjaneya
<Ve...@travelocity.com> wrote:
> Hi,
>
> I use Solr 1.4 version and I have a question about SOLR sort order.
> Requirement : Sort  names(e.g. : location names like Dallas(City), las vegas(City), Texas(State), India(Country), Canada(Country), etc..) based on category(e.g. : CITY, STATE, COUNTRY, etc..)
> How to sort the SOLR results based on custom order?
> Expected result :
>
> 1.       Dallas
>
> 2.       Las Vegas
>
> 3.       Texas
>
> 4.       Canada
>
> 5.       India
>
> Thanks & Regards, Gupta