简体   繁体   English

需要限制弹性搜索中用于构面的行

[英]Need to limit rows used for facets in elastic search

Is there a way to limit number of rows that are used for facet aggregates? 有没有一种方法可以限制用于方面聚合的行数? For example: If my query filters records by date and also has size of 300, facets ignore the size and just return facets for that date range. 例如:如果我的查询按日期过滤记录,并且大小也为300,则构面将忽略该大小,仅返回该日期范围内的构面。 Is there a way to just return facets only for these 300 records? 有没有办法只返回这300条记录的构面?

curl -X GET 'localhost:9200/some_index/some_type/_search?routing=1&search_type=count&size=300&pretty' -d '{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "account:1"
          }
        },
        {
          "query_string": {
            "query": "\"postedTime:[2013-06-12T01:00 TO 2013-06-19T01:00]\""
          }
        }
      ]
    }
  },
  "sort": [
    {
      "postedTime": "asc"
    }
  ],
  "facets": {
    "products": {
      "terms": {
        "field": "product",
        "size": 10,
        "all_terms": false
      }
    },
    "types": {
      "terms": {
        "field": "type",
        "size": 10,
        "all_terms": false
      }
    }
  },
  "size": 300,
  "version": true
}'

I'm afraid it's not possible with one request now. 恐怕现在只有一个请求是不可能的。

You can do search for first request and then with the returned IDs do ids filter with your facets as a second request, using a filtered query. 你可以做搜索的第一个请求,然后用返回的编号可能ids过滤你的面作为第二请求,使用filtered查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM