【问题标题】:Elasticsearch filtered query with script for term frequencyElasticsearch 过滤查询,带有用于词频的脚本
【发布时间】:2016-07-29 19:09:06
【问题描述】:

我正在使用附件插件:https://github.com/elastic/elasticsearch-mapper-attachments

我能够在 1 个或多个字段中找到包含特定词的文档,但无法过滤词频低于搜索词频的文档。

这行得通:

POST /crm/employee/_search
{
"query": {"filtered": {
    "query": {"match": {
       "employee.cv.content": "transitie"
    }}, 
    "filter": {
       "bool": {
           "should": [
              {"terms": {
                 "employee.listEmployeeType.id": [
                    2
                 ]
              }}
           ]
       }
   }
}},
"highlight": {"fields": {"employee.cv.content" : {}}}
}

经过长时间的搜索,我发现了以下内容:

"script": {
          "script": "crm['employee.cv.content'][lookup].tf() > occurrence",
          "params": {
              "lookup": "transitie",
              "occurrence": 1
          }
       },

很遗憾,我无法实现它。我希望我已经很好地解释了这个问题,以便有人能够推动我朝着正确的方向前进!

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:
    {
      "query": {
        "filtered": {
          "query": {
            "match": {
              "employee.cv.content": "transitie"
            }
          },
          "filter": {
            "bool": {
              "should": [
                {
                  "terms": {
                    "employee.listEmployeeType.id": [
                      2
                    ]
                  }
                }
              ],
              "must": [
                {
                  "script": {
                    "script": "_index['employee.cv.content'][lookup].tf() > occurrence",
                    "params": {
                      "lookup": "transitie",
                      "occurrence": 1
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "highlight": {
        "fields": {
          "employee.cv.content": {}
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-09-08
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-09
      相关资源
      最近更新 更多