{
"global_string_mv": {
"match_mapping_type": "string",
"match": "global*_string_mv",
"mapping": {
"type": "text",
"copy_to": "global_fields_string_mv",
"fields": {
"text_en": {
"type": "text",
"analyzer": "text_en_index",
"search_analyzer": "text_en_query"
},
"text_en_shingle": {
"type": "text",
"analyzer": "text_shingle_en_index",
"search_analyzer": "text_shingle_en_query"
},
"keyword": {
"type": "keyword"
}
}
}
}
}
In elastic we have copy_to
parameter for copying the fields.
Is there any way to replicate the same in mongodb while indexing????
UPDATE :-
PUT my-index-000001
{
"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-000001/_doc/1
{
"first_name": "John",
"last_name": "Smith"
}
GET my-index-000001/_search
{
"query": {
"match": {
"full_name": {
"query": "John Smith",
"operator": "and"
}
}
}
}
The values of the first_name
and last_name
fields are copied to the full_name
field.
The first_name
and last_name
fields can still be queried for the first name and last name respectively, but the full_name
field can be queried for both first and last names.
In Elasticsearch, 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.
Similarly we need to know that is this possible from mongodb ?? If it is possible then how ??
For more details refer to below link :- https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html