原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/copy-to.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/copy-to.html
本地英文版地址: ../en/copy-to.html
重要: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 当前版本文档。
copy_to
edit
The copy_to
parameter allows you to copy the values of multiple
fields into a group field, which can then be queried as a single
field. For instance, the first_name
and last_name
fields can be copied to
the full_name
field as follows:
PUT my_index { "mappings": { "properties": { "first_name": { "type": "text", "copy_to": "full_name" }, "last_name": { "type": "text", "copy_to": "full_name" }, "full_name": { "type": "text" } } } } PUT my_index/_doc/1 { "first_name": "John", "last_name": "Smith" } GET my_index/_search { "query": { "match": { "full_name": { "query": "John Smith", "operator": "and" } } } }
The values of the |
|
The |
Some important points:
- It is the field value which is copied, not the terms (which result from the analysis process).
-
The original
_source
field will not be modified to show the copied values. -
The same value can be copied to multiple fields, with
"copy_to": [ "field_1", "field_2" ]
-
You cannot copy recursively via intermediary fields such as a
copy_to
onfield_1
tofield_2
andcopy_to
onfield_2
tofield_3
expecting indexing intofield_1
will eventuate infield_3
, instead use copy_to directly to multiple fields from the originating field.