Last active
December 21, 2015 11:08
-
-
Save darklow/6296391 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// mapping | |
{ | |
"credits": { | |
"properties": { | |
"position": { | |
"type": "integer" | |
}, | |
"person": { | |
"properties": { | |
"id": { | |
"type": "integer" | |
} | |
} | |
} | |
} | |
} | |
// query | |
{ | |
"size": 0, | |
"facets": { | |
"top_roles": { | |
"terms": { | |
"field": "credits.person.id" | |
} | |
} | |
} | |
} | |
// Solution using "nested" | |
{ | |
"query": { | |
"term": { | |
"tv": "7" | |
} | |
}, | |
"size": 0, | |
"facets": { | |
"top_cast": { | |
"terms_stats": { | |
"key_field": "credits.person.id", | |
"value_field": "credits.person.position", | |
"order": "min" | |
}, | |
"nested": "credits", | |
"facet_filter": { | |
"term": { | |
"credits.department": "actor" | |
} | |
} | |
} | |
} | |
} | |
// If count is identical for several credits items, | |
// is it possible to somehow adjust count and | |
// involve second parameter - position, that changes count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment