Skip to content

Instantly share code, notes, and snippets.

@jprante
Last active August 29, 2015 14: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 jprante/bdf9a9755a64bc23afbe to your computer and use it in GitHub Desktop.
Save jprante/bdf9a9755a64bc23afbe to your computer and use it in GitHub Desktop.
Prefix OR query with Elasticsearch
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test/docs/1' -d '
{
"content" : "foobar baz"
}
'
curl -XPUT 'localhost:9200/test/docs/2' -d '
{
"content" : "foo baz"
}
'
curl -XPUT 'localhost:9200/test/docs/3' -d '
{
"content" : "baz foo"
}
'
curl -XPUT 'localhost:9200/test/docs/4' -d '
{
"content" : "foo bazilion"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XGET 'localhost:9200/test/docs/_search?pretty' -d '
{
"query": {
"bool": {
"should" : [
{ "prefix" : { "content" : "foo" } },
{ "prefix" : { "content" : "baz" } }
]
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment