Fixes class cast exception when`top_children`, `has_child` and `has_parent` queries are cached via `fquery` filter.
The error only occurs for `has_child` and `has_parent` if `score_mode` is used.
Closes #3290