我的映射定义中包含以下字段:
... "my_field": { "type": "string", "index":"not_analyzed" } ...
当我索引用的有价票证my_field = 'test-some-another'该值被分成3个术语:test,some,another。
my_field = 'test-some-another'
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与以下API结合使用: curl -XGET localhost:9200/my_index/_termlist 这将给我以下响应: ``
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" : {为根元素。试试这个:
"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" } } } } }'