2017-04-07 120 views
0

我遇到了一些結合cutoff_frequency與「和」運算符的彈性搜索查詢,但這對我沒有意義。Elasticsearch:將cutoff_frequency與運算符相結合?

這是布爾查詢的一部分:

{ 
    "match": { 
     "content": { 
     "query": "I has candy and cake", 
     "cutoff_frequency": 0.001, 
     "operator": "and" 
     } 
    } 
    } 

並根據本文檔中cutoff_frequency會(視文件,但最有可能的)轉換成以下這一點;

{ 
    "bool": { 
    "must": { 
     "bool": { 
     "should": [ 
      { "term": { "text": "candy" }}, 
      { "term": { "text": "cake" }} 
     ] 
     } 
    }, 
    "should": { 
     "bool": { 
     "should": [ 
      { "term": { "text": "I" }}, 
      { "term": { "text": "has" }}, 
      { "term": { "text": "and" }} 
     ] 
     } 
    } 
    } 
} 

但是,因爲有一個「和」操作符添加到查詢會發生什麼?這是否意味着「cutoff_frequency」沒有效果?

回答

1

它有效果。 從技術文檔Elastic Documentation

的匹配查詢支持cutoff_frequency,允許指定的絕對或相對文檔頻率,其中高頻術語移動到一個可選的子查詢,並且只打進如果低頻率的一個(低於截止值)條款或運營商或中的所有低頻條款與運營商相匹配

更新:我在查詢被誤認爲

貌似是:

{ 
"bool": { 
    "must": { 
     "bool": { 
     "must": [ 
      { "term": { "text": "candy" }}, 
      { "term": { "text": "cake" }} 
     ] 
    } 
    }, 
"should": { 
    "bool": { 
     "should": [ 
     { "term": { "text": "I" }}, 
     { "term": { "text": "has" }}, 
     { "term": { "text": "and" }} 
     ] 
    } 
    } 
    } 
} 

,並回答你的問題在我的例子

+0

所以「是僅在這兩個術語匹配」以上,如果我的所有低頻詞彙(糖果,蛋糕)都在文檔中,高頻詞彙(I,has,and)將只對評分有貢獻? –