Get a page of products but return all product_tags for the whole unpaginated result set

Hi I have a query, which filters products and paginates the results (by ?size URL argument).
Is there a way to return just a page (?size=12) of products, but return the available product_tags for the whole lot (hits.total.value=147)?

{
    "sort": [
        {
            "menu_order": {
                "order": "ASC"
            }
        },
        {
            "name.keyword": {
                "order": "ASC"
            }
        },
        {
            "id": {
                "order": "DESC"
            }
        }
    ],
    "query": {
        "bool": {
            "filter": [
                {
                    "bool": {
                        "minimum_should_match": 1,
                        "should": [
                            {
                                "match": {
                                    "status": "publish"
                                }
                            }
                        ]
                    }
                }
            ]
        }
    },
    "aggs": {
        "my-agg-name": {
            "terms": {
                "field": "tags.id"
            }
        }
    }
}

Welcome!

That's what your request is doing.

But I only get the buckets element with a count of _docs per product_tag. I'd like to get the actual list of product_tags/ids related to that whole search.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Is the problem you're only seeing 10 ids? Try set the size property on the terms aggregation to something larger.

@dadoonet , @Mark_Harwood I guess I got crosseyed for a moment, it does return the tag ids, just didn't get the "key" part.

Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.