# \[Ann\] ICU facet allows sorting based on ICU collations

**URL:** <https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388>\
**Category:** Elasticsearch\
**Created:** [October 17, 2012, 9:04am UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388 "2012-10-17T09:04:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 17, 2012, 9:04am UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388/1 "2012-10-17T09:04:57Z")

</div>

Hi,

just a quick note, I want to draw your attention to a little feature I just  
added to the ICU plugin. A new facet type "icu" allows sorting string  
entries in facets according to ICU collation rules.

For german users, the challenge is well-known in displaying names in facets  
that are sorted appropriately even if they have umlauts  
("Telefonbuchsortierung").

Pull request here

> <https://github.com/elastic/elasticsearch-analysis-icu/pull/7>

Preliminary ZIP as drop-in replacement for the ICU plugin

[https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip](https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip)  
Cheers, Jörg

--

---

<div class="post-metadata">

**Author:** ![Tanguy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanguy1/32/1749_2.png) [@Tanguy1](https://discuss.elastic.co/u/Tanguy1)\
**Post date:** [October 17, 2012, 9:19am UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388/2 "2012-10-17T09:19:28Z")

</div>

Sounds interesting for french as well, thanks Jorg

-- Tanguy

Le mercredi 17 octobre 2012 11:04:57 UTC+2, Jörg Prante a écrit :

> Hi,
> 
> just a quick note, I want to draw your attention to a little feature I  
> just added to the ICU plugin. A new facet type "icu" allows sorting string  
> entries in facets according to ICU collation rules.
> 
> For german users, the challenge is well-known in displaying names in  
> facets that are sorted appropriately even if they have umlauts  
> ("Telefonbuchsortierung").
> 
> Pull request here  
> [Adding ICU collation based sorting for facets by jprante · Pull Request #7 · elastic/elasticsearch-analysis-icu · GitHub](https://github.com/elasticsearch/elasticsearch-analysis-icu/pull/7)
> 
> Preliminary ZIP as drop-in replacement for the ICU plugin
> 
> [https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip](https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip)  
> Cheers, Jörg

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [October 19, 2012, 7:49pm UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388/3 "2012-10-19T19:49:14Z")

</div>

Well, I had to rework the pull request - it wasn't working, but now it  
should. Sorry for the inconvenience.

Also I updated the download zip.

For users who prefer the non-ICU environment (JDK-based)  
for java.text.Collator based sorting on doc lists and facets, I issued pull  
requests:

> <https://github.com/elastic/elasticsearch/pull/2337>
>
> Hi, 
> 
> here is a non-ICU feature extension for the standard ES terms facets, whic…h may be useful in linguistic applications. 
> 
> Right now it is not possible to sort names in facet entries according to locale settings. So I have added a subpackage org.elasticsearch.search.facet.terms.comparator with a set of comparator classes. One comparator is based on java.text.Collator. Some new parameters can be given to a facet query: "locale", "reverse", "rules", "strength", and "decomp".
> 
> Test case is included in TermsFacetCollationTests.java for german and french sorting, also a rule-based demo.
> 
> Cheers, Jörg

> <https://github.com/elastic/elasticsearch/pull/2338>
>
> Hi,
> 
> this patch adds the Lucene CollationKeyAnalyzer for locale-sensitive sortin…g by using java.text.Collator. I know that ICUCollationKey is much preferable https://issues.apache.org/jira/browse/LUCENE-1719 but it could be useful for non-ICU environments, and where performance is not very important. See also my pull request for java.text.Collator based terms facet sorting. It would be nice being able to align hit sorting and terms facet sorting.
> 
> Test is included for demonstrating a collation-key based sort.
> 
> Cheers, Jörg

Cheers, Jörg

On Wednesday, October 17, 2012 11:19:28 AM UTC+2, Tanguy wrote:

> Sounds interesting for french as well, thanks Jorg
> 
> -- Tanguy
> 
> Le mercredi 17 octobre 2012 11:04:57 UTC+2, Jörg Prante a écrit :
> 
> > Hi,
> > 
> > just a quick note, I want to draw your attention to a little feature I  
> > just added to the ICU plugin. A new facet type "icu" allows sorting string  
> > entries in facets according to ICU collation rules.
> > 
> > For german users, the challenge is well-known in displaying names in  
> > facets that are sorted appropriately even if they have umlauts  
> > ("Telefonbuchsortierung").
> > 
> > Pull request here  
> > [Adding ICU collation based sorting for facets by jprante · Pull Request #7 · elastic/elasticsearch-analysis-icu · GitHub](https://github.com/elasticsearch/elasticsearch-analysis-icu/pull/7)
> > 
> > Preliminary ZIP as drop-in replacement for the ICU plugin
> > 
> > [https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip](https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip)  
> > Cheers, Jörg

--

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 20, 2012, 10:41pm UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388/4 "2012-10-20T22:41:34Z")

</div>

Great work Jorg!. We are going to go through the effort of upgrading to Lucene 4.0, and then restructure a bit the facet API code (to simplify writing custom ones for example). I would also say that, if its just for ordering, we should allow for a pluggable "sort" logic for the different terms facet, which ICU can add.

On Oct 19, 2012, at 9:49 PM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Well, I had to rework the pull request - it wasn't working, but now it should. Sorry for the inconvenience.
> 
> Also I updated the download zip.
> 
> For users who prefer the non-ICU environment (JDK-based) for java.text.Collator based sorting on doc lists and facets, I issued pull requests:
> 
> [Adding collator-based sorting for terms facet entries by jprante · Pull Request #2337 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/2337)  
> [Adding Collation Key Analyzer by jprante · Pull Request #2338 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/2338)
> 
> Cheers, Jörg
> 
> On Wednesday, October 17, 2012 11:19:28 AM UTC+2, Tanguy wrote:  
> Sounds interesting for french as well, thanks Jorg
> 
> -- Tanguy
> 
> Le mercredi 17 octobre 2012 11:04:57 UTC+2, Jörg Prante a écrit :  
> Hi,
> 
> just a quick note, I want to draw your attention to a little feature I just added to the ICU plugin. A new facet type "icu" allows sorting string entries in facets according to ICU collation rules.
> 
> For german users, the challenge is well-known in displaying names in facets that are sorted appropriately even if they have umlauts ("Telefonbuchsortierung").
> 
> Pull request here [Adding ICU collation based sorting for facets by jprante · Pull Request #7 · elastic/elasticsearch-analysis-icu · GitHub](https://github.com/elasticsearch/elasticsearch-analysis-icu/pull/7)
> 
> Preliminary ZIP as drop-in replacement for the ICU plugin  
> [https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip](https://github.com/downloads/jprante/elasticsearch-analysis-icu/elasticsearch-analysis-icu-1.8.0-SNAPSHOT.zip)
> 
> Cheers, Jörg
> 
> --

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:07am UTC](https://discuss.elastic.co/t/ann-icu-facet-allows-sorting-based-on-icu-collations/9388/5 "2017-07-06T03:07:49Z")

</div>


