0
我试图索引嵌套的数据和查询弹性搜索,但得到以下错误一个简单的嵌套数据:如何映射然后查询上elasticsearch
"filter":[]}}}]]]; nested: QueryParsingException[[products] [_na] query malformed, no field after start_object]; }]
我的映射是:
{
"product": {
"properties": {
"id": { "type": "integer", "store": true },
"description": { "type": "string" },
"kind": { "type": "string" },
"name": { "type": "string", "store": true },
"tags": {
"type": "nested",
"properties": {
"label": {
"type": "string",
"index": "not_analyzed",
"omit_norms": true,
"index_options": "docs"
},
"slug": {
"type": "string",
"index": "not_analyzed",
"omit_norms": true,
"index_options": "docs"
}
}
}
}
}
}
我成功地让所有的耳机下面的查询:
{
"query": {
"filtered": {
"query": {
"bool": {
"must": {
"match": { "kind": "Headphone" }
},
"must_not": [],
"should": []
}
},
"filter": []
}
}
}
我的问题是什么是正确的查询STRU找到“带XX标记的耳机”或“具有XX和YY标签的耳机(另一个查询)”,同时支持方面?
我只是试图查询部分合并以下上面的查询,但我不能找出“正确”的地方(键)把它:
{
"nested": {
"path": "tags",
"filter": {
"bool": {
"must": {
"terms": {
"tags.slug": [ "discount", "black"],
"minimum_should_match": 1
}
}
}
}
}
}
哦谢谢你的回答。有几个问题。我只是更新了有问题的映射,现在阅读了一些关于这些问题的文档.. – edigu
这里是一个完整的工作示例,以防您有任何困难 - https://gist.github.com/imotov/eb0f09a58668af4b726f – imotov