【发布时间】:2017-03-22 01:10:02
【问题描述】:
全部。 我正在使用 ElasticSearch 5.0,我有下一个映射:
{
"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}
}
}
}
}
}
}
然后我添加一个文档:
{
"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"}
]
}
当我使用“stored_fields”查询时,结果中没有字段:
_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 吗?
谢谢。
【问题讨论】:
标签: elasticsearch elasticsearch-net