我使用5.2版本GROUP BY在elasticsearch
想写一个GROUP BY查询弹性搜索我要查询的数据,并限制下来到那些有特定的“标签”。在下面的情况下。我想在标题或内容字段中选择包含单词“FIY”的项目,然后将其缩小以仅搜索具有标签“FIY”和“Competition”的文档。
查询部分很好但我正在努力限制它给定的标签。
到目前为止,我得到了,但我得到的错误。
“原因”: “[BOOL]查询不支持[条款]”,
GET advice-articles/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "FIY",
"fields": ["title", "content"]
}
}
], "filter": {
"bool": {
"terms": {
"tags.tagName": [
"competition"
]
}
}
}
}
}
}
的示例索引是
"_index": "advice-articles",
"_type": "article",
"_id": "1460",
"_score": 4.3167734,
"_source": {
"id": "1460",
"title": "Your top FIY tips",
"content": "Fix It Yourself in April 2012.",
"tags": [
{
"tagName": "Fix it yourself"
},
{
"tagName": "customer tips"
},
{
"tagName": "competition"
}
]
我有对应关系如下
{
"advice-articles": {
"mappings": {
"article": {
"properties": {
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tags": {
"type": "nested",
"properties": {
"tagName": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}
我认为当你写“布尔”时必须遵循“必须”,“应该”,“过滤器”或“must_not”。请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html – Adonis