How to not-analyze in ElasticSearch?

前端 未结 3 1117
攒了一身酷
攒了一身酷 2020-11-30 01:29

I\'ve got a field in an ElasticSearch field which I do not want to have analyzed, i. e. it should be stored and compared verbatim. The values will contain letters, numbers,

3条回答
  •  春和景丽
    2020-11-30 02:22

    keyword analyser can be also used.

    // don't actually use this, use "index": "not_analyzed" instead
    {
      "my_type": {
        "properties": {
          "my_field1": { "type": "string", "analyzer": "english" },
          "my_field2": { "type": "string", "analyzer": "keyword" }
        }
      }
    }
    

    As noted here: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html, it makes more sense to mark those fields as not_analyzed.

    But keyword analyzer can be useful when it is set by default for whole index.

    UPDATE: As it said in comments, string is no longer supported in 5.X

提交回复
热议问题