2017-03-17 58 views
1

理想情況下,我需要計算在城市名稱中使用「倫敦」的次數。但查詢返回「倫敦」,「倫敦」和「LoNdOn」等不同的值。 我已經嘗試使用不區分大小寫作爲選項,但它不會給我所需的結果。德魯伊查詢不返回大小寫聚合不敏感結果

這裏是我的查詢,

{ 
"queryType": "topN", 
"dataSource": "wikiticker", 
"dimension":"cityName", 
"granularity": "ALL", 
"metric": "count", 
"threshold": 10, 
"filter": 
     { 
      "type": "search", 
      "dimension": "cityName", 
      "query": { 
       "type": "insensitive_contains", 
       "value": "london",     
       } 
      }, 
"aggregations": [ 
     { 
      "type": "longSum", 
       "name": "count", 
      "fieldName": "count" 
     } 
     ], 
"intervals": ["2014-10-01T00:00:00.000Z/2016-10-07T00:00:00.000Z"] 
} 

這是我的結果:

 [ { 
    "timestamp" : "2015-09-12T00:46:58.771Z", 
     "result" : [ { 
     "count" : 21, 
     "cityName" : "London" 
     }, 
     { 
      "count" : 10, 
      "cityName" : "New London" 
     }, 
     { 
      "count" : 3, 
      "cityName" : "london" 
     }, 
     { 
      "count" : 1, 
      "cityName" : "LoNdon" 
     }, 
     { 
      "count" : 1, 
      "cityName" : "LondOn" 
     } ] 
     } ] 

我應該得到的東西,如:

 [ { 
      "timestamp" : "2015-09-12T00:46:58.771Z", 
      "result" : [ { 
      "count" : 26, 
      "cityName" : "London" 
      }, 
      { 
      "count" : 10, 
      "cityName" : "New London" 
      } ] 
     } ] 
+0

所以現在insensitive_contains越來越我,我需要不論搜索關鍵詞中提供的情況下的值,但是我現在有將所有具有相似詞語但不同情況的值統計在一起,而不是單獨計算 – Anonymous

回答

0

使用過濾聚合:

已過濾的聚合器將包裝任何給定的聚合器,但只聚合給定維度過濾器所匹配的值。

{ 
    "type" : "filtered", 
    "filter" : { 
      "type" : "search", 
      "dimension" : cityName, 
      "query": { 
         "type":"contains", 
         "value":"london" 
         }   
      }, 
    "aggregator" : { 
       "type": "count", 
       "name": "Total Count of the Name London" 
       } 
} 

參考

+0

nope,此解決方案不起作用。不管怎麼說,還是要謝謝你。 – Anonymous