2017-06-23 44 views
0

對於實施例I具有Elasticsearch指數和類型映射如下:Elasticsearch如何在我們搜索文檔時獲取所有映射字段?

PUT /index 
{"mappings": { 
"type": { 
    "properties":{ 
    "title":{ 
    "type":"string" 
    } , 
    "name":{ 
     "type":"string" 
    }, 
    "warning":{ 
     "type":"string" 
      } 
     } 
    } 

} } 和我有一個文檔等

Document 1: {"type":"type text","name":"name text"} 

現在當我查詢文獻1,因爲我有不索引warning字段,但我已經創建了它的映射,我需要warning值爲空。這是我的迴應應該是{" type":"type text","name":"name text","warning": null}這是可能的Elasticsearch和/或雖然索引是否需要的地圖warning字段爲空或我缺少別的東西。請幫忙。我正在使用Elasticsearch版本2.3.1

回答

0

Elasticsearch準確地返回了您索引的內容(與您的初始文檔完全相同),因此您需要明確索引"warning":null,以便您可以取回"warning":null

相關問題