Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Name query filtered by birthday and geo distance
curl -XGET 'http://127.0.0.1:9200/test/member/_search?pretty=1' -d '
{
"query" : {
"filtered" : {
"filter" : {
"and" : [
{
"term" : {
"birthday" : "1970-10-24"
}
},
{
"geo_distance" : {
"location" : [
51.50853,
-0.12574
],
"distance" : "100km"
}
}
]
},
"query" : {
"bool" : {
"should" : [
{
"text" : {
"first_name" : {
"boost" : 1,
"query" : "rob smith"
}
}
},
{
"text" : {
"first_name.partial" : "rob smith"
}
},
{
"text" : {
"first_name.metaphone" : "rob smith"
}
},
{
"text" : {
"last_name" : {
"boost" : 1,
"query" : "rob smith"
}
}
},
{
"text" : {
"last_name.partial" : "rob smith"
}
},
{
"text" : {
"last_name.metaphone" : "rob smith"
}
}
]
}
}
}
}
}
'
# [Mon Jul 18 13:05:04 2011] Response:
# {
# "hits" : {
# "hits" : [
# {
# "_source" : {
# "location" : [
# 51.50853,
# -0.12574
# ],
# "member_id" : "ABC-1234",
# "birthday" : "1970-10-24",
# "first_name" : "Robert",
# "last_name" : "Smith"
# },
# "_score" : 0.030499782,
# "_index" : "test",
# "_id" : "KAz-s1E1SL-pZx1N7sYFqA",
# "_type" : "member"
# }
# ],
# "max_score" : 0.030499782,
# "total" : 1
# },
# "timed_out" : false,
# "_shards" : {
# "failed" : 0,
# "successful" : 5,
# "total" : 5
# },
# "took" : 15
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.