【发布时间】:2015-07-02 00:21:09
【问题描述】:
所以我有一个这样创建的弹性搜索索引:
curl -XPUT 'http://localhost:9200/person' -d '{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
}'
在查询名为“ian”的人时,我得到两个结果
curl -XGET http://localhost:9200/person/_search -d '{
"query": {
"match": {
"_all": "ian"
}
}
}’
但是在仅查询字母 ia 时,我应该得到尽可能多或更多的结果,但我没有得到任何结果:
curl -XGET http://localhost:9200/person/_search -d '{
"query": {
"match": {
"_all": "ia"
}
}
}’
我的edge_ngram 过滤器设置有问题吗?我该如何解决这个问题?
编辑:澄清一下,我希望我的插入语句看起来像这样
curl -XPOST "http://localhost:9200/person/RANDOM_STRING HERE/ANOTHER_RANDOM_STRING" -d "{
"field1" : "value",
"field2" : "value",
"field3" : "value"
}"
插入后,我希望对所有字段进行 edge_ngram 分析,以便我可以按任何这些字段的部分字符串搜索并返回此结果。
【问题讨论】:
标签: elasticsearch lucene n-gram