Skip to content

Instantly share code, notes, and snippets.

@zibarth
Created June 1, 2012 18:05
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 zibarth/2854076 to your computer and use it in GitHub Desktop.
Save zibarth/2854076 to your computer and use it in GitHub Desktop.
ElsaticSearch mapping and documents demonstrating the WAS problem
#Create index
curl -XPUT localhost:9200/test -d '
{
"test" : {
"test" : {
"properties" : {
"tripFrom" : {"type" : "string"},
"tripTo":{"type":"string"}
}
}
}
}
'
#Insert first document
curl -XPUT localhost:9200/test/test/1 -d '
{
"tripFrom" : "WAS",
"tripTo" : "NYC"
}
'
#Insert second document
curl -XPUT localhost:9200/test/test/2 -d '
{
"tripFrom" : "NYC",
"tripTo" : "CHI"
}
'
#Search for tripFrom=NYC. ES returns the 2nd document.
curl -XGET localhost:9200/test/_search -d '
{
"query" : {
"query_string" : {
"default_field" : "tripFrom",
"query" : "NYC"
}
}
}
'
#Search for tripFrom=WAS. ES should find the 1st document, but instead there are NO results.
curl -XGET localhost:9200/test/_search -d '
{
"query" : {
"query_string" : {
"default_field" : "tripFrom",
"query" : "WAS"
}
}
}
'
#Search for tripTo=NYC. ES now returns the 1st document.
curl -XGET localhost:9200/test/_search -d '
{
"query" : {
"query_string" : {
"default_field" : "tripTo",
"query" : "NYC"
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment