【发布时间】:2016-06-24 15:55:14
【问题描述】:
我不知道为什么,使用URI Search的方式搜索文档是返回正确的文档,但是如果我使用API DSL,则找不到该文档。
重现问题:
在没有创建任何索引的情况下,我插入了这个文档:
curl http://localhost:9299/integrationtest-index/searchable/ID_XXXX2 -d '{ "ref" : "XXXX2", "field1" : "value1" }'
所以索引是使用默认映射自动创建的(类型可搜索):
curl http://localhost:9299/integrationtest-index?pretty
{
"integrationtest-index" : {
"aliases" : { },
"mappings" : {
"searchable" : {
"properties" : {
"field1" : {
"type" : "string"
},
"ref" : {
"type" : "string"
}
}
}
},
"settings" : {
"index" : {
"field1" : "value1",
"ref" : "XXXX2",
"number_of_shards" : "5",
"creation_date" : "1466780216631",
"number_of_replicas" : "1",
"uuid" : "GBj2VF-wQy6JP74AqoIn5g",
"version" : {
"created" : "2020099"
}
}
},
"warmers" : { }
}
}
此查询返回一个文档:
curl http://localhost:9299/integrationtest-index/searchable/_search?q=ref:XXXX2
但是这个不存在的其他查询响应:
curl -XPOST http://localhost:9299/integrationtest-index/searchable/_search/exists -d '
{
"query": {
"term" : {
"ref" : "XXXX2"
}
}
}'
为什么最后一个查询说文档不存在?
环境:
- 弹性搜索 2.2.0
- Ubuntu 16.04 LTS
- OpenJDK 运行时环境(内部版本 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14)
【问题讨论】:
标签: elasticsearch