繁体   English   中英

ElasticSearch-具有范围的重要术语聚合

[英]ElasticSearch - significant term aggregation with range

我很想知道如何为重要的术语汇总查询添加范围。 例如:

{
  "query": {
     "terms": {
         "text_content": [
             "searchTerm"
          ]
     },
"range": {
  "dateField": {
    "from": "date1",
    "to": "date2"
    }
  }
},
"aggregations": {
    "significantQTypes": {
         "significant_terms": {
             "field": "field1",
             "size": 10
      }
    }
 },
 "size": 0
}

不管用。 有关如何指定范围的任何建议?

与其使用范围查询,不如使用范围过滤器,因为相关性/得分在您的情况下似乎无关紧要。

然后,为了将查询与range过滤器结合起来,应该使用filtered查询(请参阅文档 )。

尝试这样的事情:

{
  "query": {
    "filtered": {
      "query": {
        "terms": {
          "text_content": [
            "searchTerm"
          ]
        }
      },
      "filter": {
        "range": {
          "dateField": {
            "from": "date1",
            "to": "date2"
          }
        }
      }
    }
  },
  "aggs": {
    "significantQTypes": {
      "significant_terms": {
        "field": "field1",
        "size": 10
      }
    }
  },
  "size": 0
}

希望这可以帮助!

暂无
暂无

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

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