Skip to content

Instantly share code, notes, and snippets.

@jippeholwerda
Created April 19, 2013 13:01
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 jippeholwerda/5420204 to your computer and use it in GitHub Desktop.
Save jippeholwerda/5420204 to your computer and use it in GitHub Desktop.
ElasticSearch sorting on not_analyzed field defined for multiple index types.
curl -XPUT http://localhost:9200/test
curl -XPUT http://localhost:9200/test/test1/_mapping -d '{
"test1": {
"dynamic": "strict",
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}'
curl -XPUT http://localhost:9200/test/test2/_mapping -d '{
"test2": {
"dynamic": "strict",
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}'
curl -XPUT http://localhost:9200/test/test1/id1 -d '{ "name": "A" }'
curl -XPUT http://localhost:9200/test/test1/id2 -d '{ "name": "B" }'
curl -XPUT http://localhost:9200/test/test2/id3 -d '{ "name": "A" }'
curl -XPUT http://localhost:9200/test/test2/id4 -d '{ "name": ["A", "B"] }'
curl -XGET http://localhost:9200/test/_search -d '{
"filter": {
"and": [
{ "type": { "value": "test2" } },
{ "term": { "name": "A" } }
]
},
"sort": [ { "name": "asc" } ]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment