2016-07-15 78 views
0

我有一個看起來像這樣的指標:Elasticsearch回報嵌套對象,而他們的父母

{ 
    "mappings":{ 
     "authors":{ 
      "properties":{ 
       "books":{ 
        "type":"nested", 
        "properties":{ 
         "title":{"type":"string"}, 
         "firstSentence":{"type":"string"}, 
         "isbn":{"type":"string"}, 
         "publishDate":{"type":"date"}, 
        } 
       }, 
       "firstName":{"type":"string"}, 
       "lastName":{"type":"string"}, 
       "birthday":{"type":"date"}, 
       } 
      } 
} 

我通過Java客戶端查詢該索引。對於這個查詢,我不關心作者;我想回來的只是書。例如,我想在標題和第一句中找到所有帶有「你好」字樣的書。

目前,我使用嵌套查詢返回作者列表,然後手動解析該列表以獲取書籍。有沒有辦法讓Elasticsearch直接返回書目清單?我使用Elasticsearch版本1.5.2和Jest 0.1.6

回答