Elasticsearch中的术语Facet,如何使用相等的最小/最大值过滤掉结果?

时间:2014-12-24 10:43:01

标签: elasticsearch

我将以下术语构面查询发布到我的Elasticsearch集群。这导致数千个术语统计具有不相等的最小/最大值以及具有相等的最小/最大值的甚至更多结果。具有相等的最小/最大值(例如,min = 0,max = 0)的那些术语统计是不感兴趣的。如何调整以下查询以仅返回有趣的结果,其中术语统计的最小/最大值不同?

{
  "facets": {
    "terms": {
      "terms_stats": {
        "value_field": "amountReviews",
        "key_field": "id",
        "size": 2000000,
        "order": "count"
      },
      "facet_filter": {
        "fquery": {
          "query": {
            "filtered": {
              "query": {
                "bool": {
                  "should": [
                    {
                      "query_string": {
                        "query": "*"
                      }
                    }
                  ]
                }
              },
              "filter": {
                "bool": {
                  "must": [
                    {
                      "match_all": {}
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "size": 0
}

响应

{
  "took": 1799,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 856000,
    "max_score": 0,
    "hits": []
  },
  "facets": {
    "terms": {
      "_type": "terms_stats",
      "missing": 0,
      "terms": [
        {
          "term": "c71e8c7aceed5aaa8697bafd8a413ed0",
          "count": 7,
          "total_count": 7,
          "min": 1,
          "max": 10,
          "total": 31,
          "mean": 4.428571428571429
        },
        {
          "term": "b6e4db022e46a1ae98926c3ed24c8785",
          "count": 7,
          "total_count": 7,
          "min": 7,
          "max": 17,
          "total": 72,
          "mean": 10.285714285714286
        },
        {
          "term": "859d0f2c4c7486ed668dcc713c059a99",
          "count": 7,
          "total_count": 7,
          "min": 4,
          "max": 8,
          "total": 35,
          "mean": 5
        },
        {
          "term": "826aa5acf107b1e6c602f4450abeca7b",
          "count": 7,
          "total_count": 7,
          "min": 0,
          "max": 0,
          "total": 0,
          "mean": 0
        } , 
         ...,
         ...
      ]
    }
  }
}

0 个答案:

没有答案