Last active
August 29, 2015 14:01
-
-
Save jprante/bdf9a9755a64bc23afbe to your computer and use it in GitHub Desktop.
Prefix OR query with Elasticsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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