Skip to content

Instantly share code, notes, and snippets.

@imotov
Last active December 10, 2015 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imotov/6a96abda46d94847657d to your computer and use it in GitHub Desktop.
Save imotov/6a96abda46d94847657d to your computer and use it in GitHub Desktop.
Сopy multiple fields into a single field in ElasticSearch
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