Last active
August 29, 2015 14:13
-
-
Save junjun-zhang/54b8c7365af1a5f86694 to your computer and use it in GitHub Desktop.
Example of reverse_nested aggregation, a way to count parent docs at a nested level. This maybe a solution to the 'jumpy number' issue in consequence type etc facets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET "http://192.170.232.56:8200/gdc_v12/participant-centric/_search?pretty=1" -d ' | |
{ | |
"aggs":{ | |
"project":{ | |
"terms":{ | |
"field":"admin.disease_code", | |
"size":1000 | |
}, | |
"aggs":{ | |
"file_size":{ | |
"nested":{ | |
"path":"files" | |
}, | |
"aggs":{ | |
"file_size_sum":{ | |
"sum":{ | |
"field":"files.file_size" | |
} | |
} | |
} | |
}, | |
"files-data_type":{ | |
"nested":{ | |
"path":"files" | |
}, | |
"aggs":{ | |
"data_type":{ | |
"terms":{ | |
"field":"files.data_type", | |
"size":10000 | |
}, | |
"aggs":{ | |
"participants":{ | |
"reverse_nested":{} | |
} | |
} | |
} | |
} | |
}, | |
"files-experimental_strategy":{ | |
"nested":{ | |
"path":"files" | |
}, | |
"aggs":{ | |
"experimental_strategy":{ | |
"terms":{ | |
"field":"files.experimental_strategy", | |
"size":10000 | |
}, | |
"aggs":{ | |
"participants":{ | |
"reverse_nested":{}, | |
"aggs":{ | |
"top_participants":{ | |
"terms":{ | |
"field":"admin.disease_code" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"size":0 | |
}' | less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment