Is case-insensitive sort on keyword aggregation possible ? (ES 6.4)

Hi all !

I want to set up a case-insensitive sort order in an aggregation, made from a keyword field.

Apparently, it wasn't possible with ES 5.2 (see Keyword type: aggregation case insensitive).

I tried to deal with it on ES 6.4, but without success, using "icu_collation_keyword" subfield and "bucket sort aggregation".

Is it at least possible, in this version (6.4) ?
Has anyone already implemented it ?
If the answer is yes, so how ?

Thanks !

Would that help? https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html

Hi @dadoonet !
I don't think so, because I want my aggregation returns original values, not normalized.
My values (people names) are international, I want to keep uppercase and accents (that's why I test with the ICU plugin).

1 Like

You could add an additional field with the normalizer just for sorting? So you have both the original value and the normalized one.

Hi @xeraa !
I tried this with Bucket Sort Aggregation, but ES tells me :

buckets_path must reference either a number value or a single value numeric metric aggregation

My aggregation looks like this, where "creator" is my keyword field and "creator.sort" my "icu_collation_keyword" subfield :

{
  "aggs": {
    "personnes": {
      "terms": {
        "field": "creator",
        "min_doc_count": 1
      },
      "aggs": {
        "creator_sort": {
          "terms": {
            "field": "creator.sort"
          }
        },
        "personnes_bucket_sort": {
          "bucket_sort": {
            "sort": [
              {
                "creator_sort": {
                  "order": "asc"
                }
              }
            ],
            "size": 50
          }
        }
      }
    }
  }
}

Maybe I'm doing wrong ?

Hi @elastic !
Any idea ?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.