_source__all特性
_source/_all特性效果
Elasticsearch • liushui00001 发表了文章 • 3 个评论 • 4033 次浏览 • 2017-05-05 18:13
我经过实际测试es5.2.2,发现_source/_all特性很好用:
1. _source可用通过配置includes、excludes获取应用需要的field
"_source": {
"enabled": true,
"includes": [
"comId",
"name",
"userName",
"equips.name",
"equips.amount"
],
"excludes": [
"phone",
"equips.code"
]
},
2.设置enabled=false关闭_source功能,关闭后,查询结果只返回doc的ID,而不会返回_source
"_source": {
"enabled": false,
3._all、include_in_all结合使用,是用户可用通过_all分词查询多个字段,而不需要写多个查询条件
"mappings": {
"testdoc03": {
"_all": {
"enabled": true
},
"_source": {
"enabled": false,
"includes": [
"comId",
"name",
"userName",
"equips.name",
"equips.amount"
],
"excludes": [
"phone",
"equips.code"
]
},
"properties": {
"comId": {
"type": "long"
},
"equips": {
"properties": {
"amount": {
"type": "double",
"include_in_all": true
},
"code": {
"type": "text"
},
"name": {
"type": "text",
"include_in_all": true
}
}
},
"name": {
"type": "text",
"include_in_all": true
},
"phone": {
"type": "keyword"
},
"userName": {
"type": "text",
"include_in_all": true
}
}
}
}
}
_source/_all特性效果
Elasticsearch • liushui00001 发表了文章 • 3 个评论 • 4033 次浏览 • 2017-05-05 18:13
我经过实际测试es5.2.2,发现_source/_all特性很好用:
1. _source可用通过配置includes、excludes获取应用需要的field
"_source": {
"enabled": true,
"includes": [
"comId",
"name",
"userName",
"equips.name",
"equips.amount"
],
"excludes": [
"phone",
"equips.code"
]
},
2.设置enabled=false关闭_source功能,关闭后,查询结果只返回doc的ID,而不会返回_source
"_source": {
"enabled": false,
3._all、include_in_all结合使用,是用户可用通过_all分词查询多个字段,而不需要写多个查询条件
"mappings": {
"testdoc03": {
"_all": {
"enabled": true
},
"_source": {
"enabled": false,
"includes": [
"comId",
"name",
"userName",
"equips.name",
"equips.amount"
],
"excludes": [
"phone",
"equips.code"
]
},
"properties": {
"comId": {
"type": "long"
},
"equips": {
"properties": {
"amount": {
"type": "double",
"include_in_all": true
},
"code": {
"type": "text"
},
"name": {
"type": "text",
"include_in_all": true
}
}
},
"name": {
"type": "text",
"include_in_all": true
},
"phone": {
"type": "keyword"
},
"userName": {
"type": "text",
"include_in_all": true
}
}
}
}
}