2016-07-29 71 views
2

我使用的附件插件:https://github.com/elastic/elasticsearch-mapper-attachmentsElasticsearch过滤查询与脚本词频

我能找到一个特定的Word文档中的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 
      } 
     }, 

我无法不幸的是实现它。我希望我已经解释了这个问题,足以让某个人向正确的方向推进!

回答

0
{ 
    "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": {} 
    } 
    } 
}