Is it possible to combine a custom score query with a filtered query?

I have two queries that i've obtained during testing and vetting of
Elasticsearch. The last part of this process is to merge the parts of both
queries into one query if possible. Ultimately, is it possible to combine a
custom score query with a filtered query? Both queries are listed below. I
have tried a bunch of different "ideas" but nothing has worked so far.

Note: I am actually using the Java API so I will need to translate the
final query into Java. Any assistance or hints towards that end would be
greatly appreciated.

Custom Score Query

{
"query" :{
"custom_score": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"script" : "citymapsscript",
"params" :{
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}

Filtered Query:
*
*
{
"from": 0,
"size": 50,
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 40.76405282025,
"lon": -73.972994269042
}
}
}
}
}
}

--

The following MIGHT have done it:

{
"query" :{
"custom_score": {
"query" :{
"filtered": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 40.76405282025,
"lon": -73.972994269042
}
}
}
}
},
"script" : "citymapsscript",
"params" :{
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}

On Wednesday, December 5, 2012 2:02:02 PM UTC-5, Anthony Campagna wrote:

I have two queries that i've obtained during testing and vetting of
Elasticsearch. The last part of this process is to merge the parts of both
queries into one query if possible. Ultimately, is it possible to combine a
custom score query with a filtered query? Both queries are listed below. I
have tried a bunch of different "ideas" but nothing has worked so far.

Note: I am actually using the Java API so I will need to translate the
final query into Java. Any assistance or hints towards that end would be
greatly appreciated.

Custom Score Query

{
"query" :{
"custom_score": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"script" : "citymapsscript",
"params" :{
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}

Filtered Query:
*
*
{
"from": 0,
"size": 50,
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 40.76405282025,
"lon": -73.972994269042
}
}
}
}
}
}

--

Yep, correct, I was about to reply.

Something like this with the Java API:

QueryBuilders.customScoreQuery(
QueryBuilders.filteredQuery(
QueryBuilders.multiMatchQuery("italian", "name",
"tags"),

FilterBuilders.geoDistanceFilter("geo_distance").distance("5km").lat(40.76405282025).lon(-73.972994269042)))
.script("citymapsscript").param("lat",
40.76405282025).param("lon", -73.972994269042);

Cheers

On Wednesday, December 5, 2012 8:59:56 PM UTC+1, Anthony Campagna wrote:

The following MIGHT have done it:

{
"query" :{
"custom_score": {
"query" :{
"filtered": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 40.76405282025,
"lon": -73.972994269042
}
}
}
}
},
"script" : "citymapsscript",
"params" :{
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}

On Wednesday, December 5, 2012 2:02:02 PM UTC-5, Anthony Campagna wrote:

I have two queries that i've obtained during testing and vetting of
Elasticsearch. The last part of this process is to merge the parts of both
queries into one query if possible. Ultimately, is it possible to combine a
custom score query with a filtered query? Both queries are listed below. I
have tried a bunch of different "ideas" but nothing has worked so far.

Note: I am actually using the Java API so I will need to translate the
final query into Java. Any assistance or hints towards that end would be
greatly appreciated.

Custom Score Query

{
"query" :{
"custom_score": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"script" : "citymapsscript",
"params" :{
"lat": 40.76405282025,
"lon": -73.972994269042
},
"lang": "native"
}
}
}

Filtered Query:
*
*
{
"from": 0,
"size": 50,
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "italian",
"fields": [
"name",
"tags"
]
}
},
"filter": {
"geo_distance": {
"distance": "5km",
"location": {
"lat": 40.76405282025,
"lon": -73.972994269042
}
}
}
}
}
}

--