2016-11-08 116 views
0

全部。 我使用ElasticSearch 5.0和我有一個映射:在結果我無法嵌套stored_fields

{ 
    "attributes":[ 
     {"name":"attribute_string", "value":"string_value","converted":null,"datetimestamp":null}, 
     {"name":"attribute_double", "value":"1234.567","converted":1234.567,"datetimestamp":null}, 
     {"name":"attribute_datetime", "value":"2015-01-01T12:10:30Z","converted":null,"datetimestamp":"2015-01-01T12:10:30Z"} 
     ]  
} 

當我詢問W /「stored_fields」,我沒有字段:

{ 
    "mappings": { 
     "object":{ 
      "properties":{ 
       "attributes":{ 
        "type":"nested", 
        "properties":{ 
         "name": { "type": "keyword", "store":true}, 
         "value": { "type": "text", "store":true }, 
         "converted": {"type": "double", "store":true}, 
         "datetimestamp": { "type": "date", "store":true} 
        } 
       } 
      } 
     } 
    } 
} 

然後,添加一個文件:

_search 
{ 
    "stored_fields":["attributes.converted"] 
} 

結果:

{ 
    "_index": "test_index", 
    "_type": "object", 
    "_id": "1", 
    "_score": 1 
} 

但是當我使用 「_source」: 「attributes.converted」],我有結果:

{ 
    "_index": "test_index", 
    "_type": "object", 
    "_id": "1", 
    "_score": 1, 
    "_source": { 
     "attributes": [ 
      { "converted": null }, 
      { "converted": 1234.567 }, 
      { "converted": null  } 
     ] 
    } 
} 

什麼是使用stored_fields的正確方法? 與「stored_fields」方法相比,「_source」的用法是否會影響性能?

如果「_source」方法與「stored_fields」一樣快,我應該刪除「store」:對於字段是否爲true?

謝謝。

回答