Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matthiasg/2b8748cfdf919ce77c3fd0438613cee6 to your computer and use it in GitHub Desktop.
Save matthiasg/2b8748cfdf919ce77c3fd0438613cee6 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"
}
}
}
@mrkk
Copy link

mrkk commented Jan 14, 2019

what if we needed to have results where filter needs to apply to both parent and child ?

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