How search with limit and top results?

I want to sort 7 most expansive products with validate time ascending. I did:

"from": 0,
"size": 7,
"query": {
    "filtered": {
        "query": {
            "match_all": {}
"sort": [{
    "price": {
        "order": "desc"
}, {
    "validate_time": {
        "order": "asc"

But I want this top 7 expansive products ordered by validate_time

What you've got will sort products by price, breaking ties with validation_time. I don't believe there is a way to get the top 7 by price and then sort them by something else.

Perhaps with the query rescorer?

There is no explicit sorting in the query scorer, your scorer will need to
submit a score based on the field. Should be easy with a date field.


Yes! That'll do it! I'd forgotten about the rescorer.

Thanks, Ill take a look! =D