You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by egorlex <eg...@gmail.com> on 2019/01/15 16:59:19 UTC

Lucene sort in AaZz order

Hi 

Hi all, i need help with understand how Lucene sort works.

This is example how i create sort field.

 document.add(new SortedDocValuesField("by_name", new
BytesRef(family.getName())));

And when i make sort by name i get result in this order - azAz, but i need
AaZz.

Could someone help me with this?

Thanks. 




--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Lucene sort in AaZz order

Posted by Trejkaz <tr...@trypticon.org>.
On Wed, Jan 16, 2019 at 2:29 AM Adrien Grand <jp...@gmail.com> wrote:
>
> Assuming that you need case-insensitive sort, the most straightforward
> way to do this would be to index the lowercase family name:
> SortedDocValuesField("by_name", new
> BytesRef(family.getName().toLowerCase(Local.ROOT))).
>
> It is also possible to implement a custom FieldComparatorSource, but
> this will likely be both more complicated and slower.

Probably actually want to use
toUpperCase(Locale.ROOT).toLowerCase(Locale.ROOT), and possibly even a
Normalizer.normalize before that. Unless you can use ICU's normaliser
with built-in case folding, which simplifies it a lot.

TX

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Lucene sort in AaZz order

Posted by Adrien Grand <jp...@gmail.com>.
Assuming that you need case-insensitive sort, the most straightforward
way to do this would be to index the lowercase family name:
SortedDocValuesField("by_name", new
BytesRef(family.getName().toLowerCase(Local.ROOT))).

It is also possible to implement a custom FieldComparatorSource, but
this will likely be both more complicated and slower.

On Tue, Jan 15, 2019 at 5:59 PM egorlex <eg...@gmail.com> wrote:
>
> Hi
>
> Hi all, i need help with understand how Lucene sort works.
>
> This is example how i create sort field.
>
>  document.add(new SortedDocValuesField("by_name", new
> BytesRef(family.getName())));
>
> And when i make sort by name i get result in this order - azAz, but i need
> AaZz.
>
> Could someone help me with this?
>
> Thanks.
>
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


-- 
Adrien

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org