通过另一个字段过滤elasticsearch中的multi_match查询

 牛牛发的 发布于 2023-01-15 12:22

我正在尝试使用ElasticSearch执行搜索,该搜索必须匹配部分索引中的某些搜索项,但仅适用于属于某些项目的部分,即当前用户可以访问的项目.

所以我试图将一个过滤器应用于查询,以便它过滤那些将project_id包含在一小组2或3个不同值中的部分.如果某个部分的project_id属于有效的project_id,则应该包含它.否则它不会.

这都是使用elasticsearch-model gem的rails api的上下文.

这是我传入的查询.它假装过滤部分,因此只有项目2和5中的部分包含在结果中.

{
  "query": {
    "filtered": {
      "query": {
        "multi_match": {
          "query": "search terms here",
          "type": "cross_fields",
          "fields": ["title^3", "contents"],
          "operator": "and"
        }
      },
      "filter": {
        "or": {
          "filters": [
            { "exists": { "project_id": 2 } },
            { "exists": { "project_id": 5 } }
          ]
        }
      }
    }
  }
}

我收到这个错误:

QueryParsingException[[sections] [exists] filter does not support [project_id]]

有任何想法吗?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有