Skip to content

Instantly share code, notes, and snippets.

@robinloxley1
Created February 29, 2016 03:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save robinloxley1/7ea7c4f37a3413b1ca16 to your computer and use it in GitHub Desktop.
Save robinloxley1/7ea7c4f37a3413b1ca16 to your computer and use it in GitHub Desktop.
sample elasticsearch query to sort parent based on child field
{
"query":{
"has_child":{
"query":{
"function_score":{
"functions":[
{
"field_value_factor":{
"factor":1,
"field":"count"
}
}
]
}
},
"score_mode":"avg",
"type":"my_child_doc_type"
}
}
}
@poonamagashe
Copy link

poonamagashe commented Jun 15, 2017

Heyy,How can we write this query in Java API Spring data elasticsearch using QueryBuilder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment