Elasticsearch filter via number of mentions

淺唱寂寞╮ 提交于 2019-12-22 01:31:51

问题


I am trying to write a query which will return me articles about certain keywords but I want the articles to only show if the the given keyword is mentions 5 times in the articles I am using following query But no result

  {
   "query":{

      "multi_match":{
         "query":"Apple",
         "operator":"AND",
         "fields":[
            "Text"
         ]

      }
      ,"min_term_freq" : 5
   },
   "sort":{
      "Date":{
         "order":"desc"
      }
   }
}

回答1:


I dont believe there is any min_term_freq option as you have listed. But then you can use scripting in filter to achieve the same -

{
  "query": {
    "filtered": {
      "filter": {
        "script": {
          "script": "_index['Text']['apple'].tf() > 5"
        }
      }
    }
  }
}


来源:https://stackoverflow.com/questions/28296320/elasticsearch-filter-via-number-of-mentions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!