【发布时间】:2020-10-01 12:19:07
【问题描述】:
我的弹性搜索索引上有这个映射:
{
"mappings": {
"properties": {
"title": {
"type": "keyword"
},
"description": {
"type": "text"
},
"content": {
"type": "text"
},
"author": {
"type": "keyword"
},
"completionTimeMinutes": {
"type": "integer"
},
"views": {
"type": "integer"
},
"questions": {
"type": "nested",
"properties": {
"question": {
"type": "keyword"
},
"answers": {
"type": "keyword"
},
"rightAnswer": {
"type": "integer"
}
}
}
}
}
}
我在从多个字段查询时遇到了一些问题。就我而言,我想搜索标题、描述、内容、questions.question、questions.answer。 我的无效查询如下所示:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "text to search i put here",
"type": "cross_fields",
"fields": [
"title",
"description",
"content",
"questions.question",
"questions.answers"
],
"slop": 1
}
}
}
}
}
我也试过{"query": { "nested": { "path": "questions", ......,其中......是上面的查询,但如果是这样,我无法搜索标题、描述、内容。所以请告诉我如何从多个嵌套级别进行查询。
【问题讨论】:
-
请仔细阅读我的回答,如果这是您的问题,请告诉我?
标签: elasticsearch