curious1
curious1

Reputation: 14717

Elasticsearch: how to return all facet values in an aggregation

I am learning Elasticsearch by reading the book called Elasticsearch Cookbook (2ed). It has the following sample query:

{
    "query": {
        "match_all": {}
    },
    "aggs": {
        "tag": {
            "terms": {
                "field": "tag",
                "size": 10
            }
        }
    }
}

According to the book,

size (by default 10): This controls the number of facets value that is to be returned.

I am curious about this: how to return all facet values if I don't know the total number of facet values in advance?

Sorry if my question is so obvious.

Thanks and regards.

Upvotes: 1

Views: 1864

Answers (1)

Perryn Fowler
Perryn Fowler

Reputation: 2232

set size to 0 (which is the same as setting it to Integer.MAX_VALUE)

Be careful though, as this will perform horribly if you have a lot of facet values.

See http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

Upvotes: 1

Related Questions