为什么Elasticsearch“not_analyzed”字段被分成术语?

2024-02-01

我的映射定义中有以下字段:

...
"my_field": {
  "type": "string",
  "index":"not_analyzed"
}
...

当我索引一个值为my_field = 'test-some-another'该值分为 3 项:test, some, another.

我究竟做错了什么?

我创建了以下索引:

curl -XPUT localhost:9200/my_index -d '{
   "index": {
    "settings": {
      "number_of_shards": 5,
      "number_of_replicas": 2
    },
    "mappings": {
      "my_type": {
        "_all": {
          "enabled": false
        },
        "_source": {
          "compressed": true
        },
        "properties": {
          "my_field": {
            "type": "string",
            "index": "not_analyzed"
          }
        }
      }
    }
  }
}'

然后我索引以下文档:

curl -XPOST localhost:9200/my_index/my_type -d '{
  "my_field": "test-some-another"
}'

然后我使用插件https://github.com/jprante/elasticsearch-index-termlist https://github.com/jprante/elasticsearch-index-termlist使用以下 API: curl -XGET localhost:9200/my_index/_termlist 这给了我以下回应:

{"ok":true,"_shards":{"total":5,"successful":5,"failed":0},"terms": ["test","some","another"]}

通过运行以下命令验证映射是否确实已设置:

curl localhost:9200/my_index/_mapping?pretty=true

创建索引的命令似乎不正确。它不应该包含"index" : {作为根元素。尝试这个:

curl -XPUT localhost:9200/my_index -d '{
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 2
  },
  "mappings": {
    "my_type": {
      "_all": {
        "enabled": false
      },
      "_source": {
        "compressed": true
      },
      "properties": {
        "my_field": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
  }
}'  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么Elasticsearch“not_analyzed”字段被分成术语? 的相关文章

随机推荐