为什么选择弹性搜索“not_analyzed”字段分为条件? [英] Why Elasticsearch "not_analyzed" field is split into terms?
问题描述
...
my_field:{
type:string,
index:not_analyzed
}
...
当我索引值为 my_field ='test-some-another'
的文档时,该值被分为3个术语: test
, some
,另一个
。
我做错了什么?
我创建了以下索引:
curl -XPUT localhost:9200 / my_index -d'{
index:{
settings:{
number_of_shards 5,
number_of_replicas:2
},
mappings:{
my_type:{
_all:{
enabled :false
},
_source:{
压缩:true
},
属性:{
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
这给了我以下响应:
{ok:true,_ shards:{总计:5,成功:5,失败:0},条件:[test,some,another]}
p $ p>
解决方案通过运行实际上设置:
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:{
压缩:true
},
属性:{
my_field:{
type:string,
index:not_analyzed
}
}
}
}
}'
I have the following field in my mapping definition:
... "my_field": { "type": "string", "index":"not_analyzed" } ...
When I index a document with value of
my_field = 'test-some-another'
that value is split into 3 terms:test
,some
,another
.What am I doing wrong?
I created the following index:
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" } } } } } }'
Then I index the following document:
curl -XPOST localhost:9200/my_index/my_type -d '{ "my_field": "test-some-another" }'
Then I use the plugin https://github.com/jprante/elasticsearch-index-termlist with the following API:
curl -XGET localhost:9200/my_index/_termlist
That gives me the following response:{"ok":true,"_shards":{"total":5,"successful":5,"failed":0},"terms": ["test","some","another"]}
解决方案Verify that mapping is actually getting set by running:
curl localhost:9200/my_index/_mapping?pretty=true
The command that creates the index seems to be incorrect. It shouldn't contain
"index" : {
as a root element. Try this: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" } } } } }'
这篇关于为什么选择弹性搜索“not_analyzed”字段分为条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!