Elasticsearch sorting on string not returning expected results

前端 未结 2 1084
一生所求
一生所求 2021-02-13 14:43

When sorting on a string field with multiple words, Elasticsearch is splitting the string value and using the min or max as the sort value. I.E.: when sorting on a field with th

2条回答
  •  别跟我提以往
    2021-02-13 15:16

    If you want the sorting to be case-insensitive "index": "not_analyzed" doesn't work, so I've created a custom sort analyzer.

    index-settings.yml

    index :   
        analysis :
            analyzer :
                sort :
                    type : custom
                    tokenizer : keyword
                    filter : [lowercase]
    

    Mapping:

    ...
    "articleName": {
        "type": "string",
        "analyzer": "standard",
        "fields": {
            "sort": {
                "type": "string",
                "analyzer": "sort"
            }
        }
    }
    ...
    

提交回复
热议问题