Skip to content

Instantly share code, notes, and snippets.

@clintongormley
Created May 24, 2012 11:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save clintongormley/2781011 to your computer and use it in GitHub Desktop.
Save clintongormley/2781011 to your computer and use it in GitHub Desktop.
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"number_of_shards" : 1
}
}
'
curl -XPUT 'http://127.0.0.1:9200/test/foo/1?pretty=1' -d '
{
"bar" : 5,
"tag" : "foo"
}
'
curl -XPUT 'http://127.0.0.1:9200/test/foo/2?pretty=1' -d '
{
"bar" : 15,
"tag" : "foo"
}
'
curl -XPUT 'http://127.0.0.1:9200/test/foo/3?pretty=1;refresh=1' -d '
{
"bar" : 30,
"tag" : "bar"
}
'
curl -XGET 'http://127.0.0.1:9200/test/foo/_search?pretty=1' -d '
{
"query" : {
"custom_filters_score" : {
"query" : {
"term" : {
"tag" : "bar"
}
},
"filters" : [
{
"boost" : "2",
"filter" : {
"range" : {
"bar" : {
"lt" : 10,
"gte" : 0
}
}
}
},
{
"boost" : "5",
"filter" : {
"range" : {
"bar" : {
"lt" : 50,
"gte" : 10
}
}
}
}
]
}
}
}
'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 7.0273256,
"hits" : [ {
"_index" : "test",
"_type" : "foo",
"_id" : "3",
"_score" : 7.0273256, "_source" :
{
"bar" : 30,
"tag" : "bar"
}
} ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment