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


#1

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 !


(David Pilato) #2

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


#3

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).


(xeraa) #4

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


#5

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 ?


#6

Hi @elastic !
Any idea ?


(system) #7

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