2015-12-22 181 views
0

我試圖在filtered查詢中使用filter,這就是我想用感:ElasticSearch過濾查詢和過濾條件

GET myindex/catalog/_search 
{ 
    "query": { 
     "filtered": { 
      "query": { 
       "query_string": { 
        "analyze_wildcard": true, 
        "query": "test", 
        "fields": ["title^3.5", "contributions.authors.name^5", "publisher^2", "formats.productCode^0.5", "description^0.1"], 
        "use_dis_max": true 
       } 
      }, 
      "filter": { 
       "term": { 
        "sku": "test-687" 
       } 
      } 
     } 
    } 
} 

此查詢也沒有任何的打擊,但如果我刪除filter屬性我得到完全與sku = test-687項目。

我不明白爲什麼與filter查詢不給我相同的結果。

映射:

{ 
    "myindex": { 
    "mappings": { 
     "catalog": { 
     "properties": { 
      "sku": { 
      "type": "string" 
      }, 
      "title": { 
      "type": "string" 
      }, 
      "updated_at": { 
      "type": "date", 
      "format": "strict_date_optional_time||epoch_millis" 
      } 
     } 
     } 
    } 
    } 
} 
+0

字段'sku'是exaclty'測試687'。 –

+0

術語是小寫/大寫。什麼是您的字段「SKU」的映射? – AlainIb

+0

我告訴過你,'test-687'就是這樣,不能成爲案件的問題。 –

回答

1

完整查詢是:

GET myindex/catalog/_search { 
    "query": { 
    "filtered": { 
     "query": { 
     "query_string": { 
      "analyze_wildcard": true, 
      "query": "test", 
       "fields": ["title^3.5", "contributions.authors.name^5", "publisher^2", "formats.productCode^0.5", "description^0.1"], 
       "use_dis_max": true 
     } 
     }, 
     "filter": { 
      "bool": { 
      "must": { 
       "query": { 
       "match": { 
        "sku": "test-687" 
       } 
       } 
      } 
      } 
     } 
    } 
    } 
} 

在默認映射 「標準分析儀中使用的」:

類型標準的分析器是使用標準令牌過濾器和標準令牌過濾器構建的案例令牌過濾器和停止令牌過濾器。

(更多細節her

期限是大小寫敏感的,不相匹配