Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在ElasticSearch中标记和排除过滤器?_Php_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Solr_Lucene_Bigdata - Fatal编程技术网 elasticsearch,solr,lucene,bigdata,Php,elasticsearch,Solr,Lucene,Bigdata" /> elasticsearch,solr,lucene,bigdata,Php,elasticsearch,Solr,Lucene,Bigdata" />

Php 如何在ElasticSearch中标记和排除过滤器?

Php 如何在ElasticSearch中标记和排除过滤器?,php,elasticsearch,solr,lucene,bigdata,Php,elasticsearch,Solr,Lucene,Bigdata,就像当为刻面/聚合过滤器设置过滤器时,它应该被排除,所以我们不会只得到一个结果 如果用户选择某个品牌,则结果应仅包含所选品牌,但聚合应返回已经存在的所有品牌过滤器,以便用户也可以选择其他品牌 我们如何在Elasticsearch中做到这一点?可以在solr中使用标记和排除过滤器访问相同的内容使用post_过滤器过滤搜索结果,但仍显示聚合中的所有数据 见: post_过滤器应用于搜索结果末尾的搜索点击 已计算聚合后的搜索请求。它是 最好用例子来说明目的: 如何检查用户是否选择了两种颜色?比如“红色

就像当为刻面/聚合过滤器设置过滤器时,它应该被排除,所以我们不会只得到一个结果

如果用户选择某个品牌,则结果应仅包含所选品牌,但聚合应返回已经存在的所有品牌过滤器,以便用户也可以选择其他品牌


我们如何在Elasticsearch中做到这一点?可以在solr中使用标记和排除过滤器访问相同的内容

使用post_过滤器过滤搜索结果,但仍显示聚合中的所有数据

见:

post_过滤器应用于搜索结果末尾的搜索点击 已计算聚合后的搜索请求。它是 最好用例子来说明目的:


如何检查用户是否选择了两种颜色?比如“红色”:我将如何创造另一个?使用or运算符。如果是,请给出JSONU使用or筛选器添加其他筛选器-是。我知道了。谢谢。)
curl -XGET localhost:9200/shirts/_search -d '
{
  "query": {
    "filtered": {
      "filter": {
        { "term": { "brand": "gucci" }} 
      }
    }
  },
  "aggs": {
    "colors": {
      "terms": { "field": "color" }, 
    },
    "color_red": {
      "filter": {
        "term": { "color": "red" } 
      },
      "aggs": {
        "models": {
          "terms": { "field": "model" } 
        }
      }
    }
  },
  "post_filter": { 
    "term": { "color": "red" },
  }
}
'