2017-09-10 95 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映射?如果您想使用术语查询,则不应分析它,因为此类查询将从索引中查找确切值。

相关问题