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