2016-07-29 65 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": {} 
    } 
    } 
}