Skip to content

Instantly share code, notes, and snippets.

@ebuildy
Last active February 29, 2016 13:48
Show Gist options
  • Save ebuildy/72fade2e26dea91256d6 to your computer and use it in GitHub Desktop.
Save ebuildy/72fade2e26dea91256d6 to your computer and use it in GitHub Desktop.
Bug elasticsearch: "match uses the wrong field"
#!/usr/bin/env bash
docker run -tid -p 9200:9200 elasticsearch:1.7.3
sleep 5
ES_URI="http://192.168.99.100:9200"
curl -XDELETE ${ES_URI}/test
curl -XPOST ${ES_URI}/test -d '
{
"settings": {
"number_of_shards": "1",
"number_of_replicas": "1"
},
"mappings" : {
"title" : {
"properties" : {
"alias" : {
"type" : "string",
"fields" : {
"simple" : {
"type" : "string"
}
}
}
}
}
}
}'
curl -XPUT ${ES_URI}/test/title/toto -d '
{
"alias" : "coca"
}'
sleep 1
echo ""
# This should return nothing but returns "toto" document
curl -XGET ${ES_URI}/test/_search?q=title.simple:coca
echo ""
# This returns nothing
curl -XGET ${ES_URI}/test/_search?q=toto.simple:coca
echo ""
# This returns "toto" document
curl -XGET ${ES_URI}/test/_search?q=alias.simple:coca
echo ""
# This should return nothing but returns "toto" document
curl -XPOST ${ES_URI}/test/_search -d '
{
"query" : {
"match" : {
"title.simple" : "coca"
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment