我正在使用Elasticsearch 5.2.2。
在我的索引中,我有如下数据:
{
"_index": "index",
"_type": "273caf76-ec03-478c-b980-9743180bc863",
"_id": "eee46e24-f383-4ae7-8930-dc3836e030a5",
"_score": 3.41408,
"_source": {
"Father Name": [
{
"id": "some id",
"value": "Some value test test"
}
],
"Mother Name": [
{
"id": "some id",
"value": "Another value haha"
}
],
"Other values": [{ id: "", value: ""}]
}
}
当我使用_all搜索时,一切正常,我可以找到所有分数合理的结果
{"query":{"match":{"_all":"value"}},"from":0,"size":20}
但是该查询正在所有字段中搜索。例如,如果我只想在
Father Name
或Father Name
和Mother Name
中找到结果,那么我什么也没找到。{"query":{"match":{"Father Name":"value"}},"from":0,"size":20}
我的目标是查找与_all类似的搜索,但仅限于几个字段。
最佳答案
您的字段Father Name
和Mother Name
是内部对象的数组。
例如,要在value
的Father Name
字段中搜索,请执行curl -XGET localhost:9200/myindex/_search?pretty -d '
{
"query": {
"match": {
"Father Name.value": "first"
}
},
"from": 0,
"size": 20
}'
但是,我不确定如何查询Father Name
中的所有字段。
引用Arrays of Inner Objects
关于elasticsearch - Elasticsearch 数组中没有匹配项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43143734/