【发布时间】:2018-11-09 01:44:46
【问题描述】:
我对弹性搜索中的术语查询有疑问。我发送以下查询:
{
"query": {
"term": {
"title":"Test1"
}
}
}
我有一个空结果:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
但如果我发送以下内容:
{
"query": {
"term": {
"root":true
}
}
}
我有:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 0.2876821,
"hits": [
{
"_index": "content_2018-05-30-092148",
"_type": "topic",
"_id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbeb1",
"_score": 0.2876821,
"_source": {
"_meta": {
"model": "Secafi\\Content\\Topic"
},
"id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbeb1",
"title": "Test2",
"root": true
}
},
{
"_index": "content_2018-05-30-092148",
"_type": "topic",
"_id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbeb2",
"_score": 0.2876821,
"_source": {
"_meta": {
"model": "Secafi\\Content\\Topic"
},
"id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbeb2",
"title": "Test3",
"root": true
}
},
{
"_index": "content_2018-05-30-092148",
"_type": "topic",
"_id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbebc",
"_score": 0.2876821,
"_source": {
"_meta": {
"model": "Secafi\\Content\\Topic"
},
"id": "6064f7ac-63d5-11e8-adc0-fa7ae01bbebc",
"title": "Test1",
"root": true
}
}
]
}
}
如果我对标题字段进行匹配查询,我会得到相同的结果,它永远不会返回任何文档。
怎么了。为什么第一个查询没有返回文档 Test1?
【问题讨论】:
-
你能展示你的映射吗?
标签: elasticsearch search term