2017-09-10 134 views
0

我一直保存在該物體像這樣ElasticSearch查詢嵌套的對象不會返回結果

{ 
    "_index": "sessions_user_dev", 
    "_type": "user", 
    "_id": "322", 
    "_version": 1, 
    "_source": { 
    "id": 322, 
    "createdAt":  "2015-07-09T00:12:45+00:00", 
    "firstName": "Amy", 
    "lastName": "John", 
    "openLocations": [ 
    { 
     "id": 4, 
     "code": "QLD", 
     "label": "Queensland", 
     "country": "AU" 
    } 
    ] 
    } 
} 

而且我想設置爲openLocations的術語,這裏是我的代碼

{ 
    "query": { 
    "term": { 
     "user.openLocations.code": { 
     "value": "QLD" 
     } 
     } 
    } 
} 

但返回零結果。我也嘗試將該字段更改爲openLocations.code,但沒有用戶盈方,但仍然沒有運氣。還試過:

{ 
    "query": { 
     "bool": { 
     "filter": { 
     "bool": { 
     "must": [ 
      { 
       "term": { 
       "openLocations.code": "QLD" 
      } 
     } 
     ] 
     } 
     } 
    } 
    } 
} 

但仍然沒有結果。試圖使用嵌套查詢,但它總是說[嵌套]無法找到路徑[user.openLocations]下的嵌套對象。

我Elasticsearch 5.4

THX提前

回答

0

什麼是openLocations.code映射?如果您想使用術語查詢,則不應分析它,因爲此類查詢將從索引中查找確切值。

相關問題