Created
December 11, 2010 20:31
-
-
Save kimchy/737631 to your computer and use it in GitHub Desktop.
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 -XPUT localhost:9200/test/type1/1 -d '{ | |
"value" : 1 | |
}' | |
curl -XPUT localhost:9200/test/type1/2 -d '{ | |
"value" : 2 | |
}' | |
curl -XPUT localhost:9200/test/type1/3 -d '{ | |
"value" : 3 | |
}' | |
curl -XPUT localhost:9200/test/type1/4 -d '{ | |
"value" : 4 | |
}' | |
curl -XPOST localhost:9200/_refresh | |
#Term query on 2 | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"term" : { | |
"value" : 2 | |
} | |
} | |
}' | |
# Query String on 2 | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"query_string" : { | |
"query" : "value:2" | |
} | |
} | |
}' | |
#Query String on 2 or 3 | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"query_string" : { | |
"query" : "value:2 OR value:3" | |
} | |
} | |
}' | |
# Query String on 2 or 3 without needing to prefix by field, since value | |
# is the default field | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"query_string" : { | |
"default_field" : "value", | |
"query" : "2 OR 3" | |
} | |
} | |
}' | |
# And field query, which is similar to query_string, simply auto | |
# setting the default_field to the field in queries on | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"field" : { | |
"value" : "2 OR 3" | |
} | |
} | |
}' | |
#And last, OR can be done with bool on term queries as well... | |
curl -XGET localhost:9200/test/_search -d '{ | |
"query" : { | |
"bool" : { | |
"should" : [ | |
{ "term" : { "value" : 2 } }, | |
{ "term" : { "value" : 3 } } | |
] | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment