Elasticsearch多值嵌套过滤

ohfgkhjo  于 2022-11-28  发布在  ElasticSearch
关注(0)|答案(1)|浏览(114)

来自FE部分i具有值阵列,通过该值阵列,i需要过滤ElasticSearch查询。
例如,从FE部分,我有这样的查询order=asc&skip=0&take=25&filter.state=free& filter.state =忙碌我解析了它并粘贴到模型中,如下所示

public class Search 
{
 public string Search { get; set; }

        public string Sort { get; set; }

        public OrderBy? Order { get; set; }

        public int Take { get; set; }

        public int Skip { get; set; }

       public Filter Filter {get;set;}
}

public class  Filter 
{
  public IEnumerable<string> statuses {get;set;}
}

我需要在我的ElasticSearch中创建按过滤器状态的搜索。

dwbf0jvd

dwbf0jvd1#

您可能正在寻找“应该”

GET myindex/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "gender": "male"
          }
        },
        {
          "term": {
            "gender": "female"
          }
        }
      ]
    }
  }
}

GET myindex/_search
{
  "query":{
    "bool": {
      "filter": [
        {
          "bool": {
            "should": [
              {
                "term": {
                  "gender": "male"
                }
              },
              {
                "term": {
                  "gender": "female"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

相关问题