Skip to content

Instantly share code, notes, and snippets.

@allancaffee
Created December 22, 2011 00:38
Show Gist options
  • Save allancaffee/1508383 to your computer and use it in GitHub Desktop.
Save allancaffee/1508383 to your computer and use it in GitHub Desktop.
ElasticSearch (version 0.18.5) term query for literal url match
curl -XPUT localhost:9200/test_a/type1/1 -d '{
"url" : "http://example.com/blog"
}'
# {"ok":true,"_index":"test_a","_type":"type1","_id":"1","_version":1}
curl localhost:9200/test_a/type1/_search?pretty=true -d '{
"query": {
"term": {
"url": "http://example.com/blog"
}
}
}'
# {
# "took" : 5,
# "timed_out" : false,
# "_shards" : {
# "total" : 6,
# "successful" : 6,
# "failed" : 0
# },
# "hits" : {
# "total" : 0,
# "max_score" : null,
# "hits" : [ ]
# }
# }
curl localhost:9200/test_a/type1/_search?pretty=true -d '{
"query": {
"match_all": {}
}
}'
# {
# "took" : 2,
# "timed_out" : false,
# "_shards" : {
# "total" : 6,
# "successful" : 6,
# "failed" : 0
# },
# "hits" : {
# "total" : 1,
# "max_score" : 1.0,
# "hits" : [ {
# "_index" : "test_a",
# "_type" : "type1",
# "_id" : "1",
# "_score" : 1.0, "_source" : {
# "url" : "http://example.com/blog"
# }
# } ]
# }
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment