Elasticsearch过滤项不工作?

2024-04-25 06:03:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获得一个非常基本的过滤查询来使用Elasticsearch。你知道吗

{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "term": {
          "name": "stanford designs"
        }
      }
    }
  }
}

Tags: namematchallfilterelasticsearchqueryboolterm
1条回答
网友
1楼 · 发布于 2024-04-25 06:03:41

奇怪的是,您的查询看起来很好,但可能您使用的是一些旧版本的Elastics。 您可以使用bool must before term filter,如下所示:

{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "name": "stanford designs"
              }
            }
          ]
        }
      }
    }
  }
}

希望这能奏效。你知道吗

相关问题 更多 >