Skip to content

Instantly share code, notes, and snippets.

@radu-gheorghe
Created July 15, 2013 14:15
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 radu-gheorghe/6000256 to your computer and use it in GitHub Desktop.
Save radu-gheorghe/6000256 to your computer and use it in GitHub Desktop.
match query on an array
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"number_of_shards": 1
}
}'
curl -XPUT localhost:9200/test/test/1 -d '{
"tags": "foo"
}'
curl -XPUT localhost:9200/test/test/2 -d '{
"tags": ["foo", "bar"]
}'
curl -XPUT localhost:9200/test/test/3 -d '{
"tags": ["foo", "bar", "baz"]
}'
curl -XPOST localhost:9200/test/_refresh
sleep 1
curl localhost:9200/test/_search?pretty -d '{
"query": {
"match": {
"tags": {
"query": "foo bar"
}
}
}}'
#2 should be first, 3 second, 1 third
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment