-
-
Save imotov/6a96abda46d94847657d to your computer and use it in GitHub Desktop.
Сopy multiple fields into a single field in ElasticSearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE localhost:9200/test-idx | |
echo | |
curl -XPUT localhost:9200/test-idx -d '{ | |
"settings": { | |
"index": { | |
"number_of_shards": 1, | |
"number_of_replicas": 0 | |
} | |
}, | |
"mappings": { | |
"doc": { | |
"properties": { | |
"first_name": { | |
"type": "multi_field", | |
"path": "just_name", | |
"fields": { | |
"first_name": {"type": "string", "index": "analyzed"}, | |
"name": {"type": "string","index": "analyzed"} | |
} | |
}, | |
"last_name": { | |
"type": "multi_field", | |
"path": "just_name", | |
"fields": { | |
"last_name": {"type": "string", "index": "analyzed"}, | |
"name": {"type": "string","index": "analyzed"} | |
} | |
} | |
} | |
} | |
} | |
}' | |
echo | |
curl -XPUT localhost:9200/test-idx/doc/1 -d '{ | |
"first_name": "Shay", | |
"last_name": "Banon" | |
}' | |
echo | |
curl -XPOST localhost:9200/test-idx/_refresh | |
echo | |
curl "localhost:9200/test-idx/doc/_search?q=name:Shay" | |
echo | |
curl "localhost:9200/test-idx/doc/_search?q=name:Banon" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment