弹性搜索:获取此结果集的可用构面/聚合列表

In Elastic Search I need to obtain a list of available Aggregations (formally Facets?) for the current result-set.

For example, if I do a search for "car" in a set of cars which have defined MAKE and MODEL fields, I would like it to not only give me a result set of cars, but also a list of makes and models I can filter by.

From what I can read, you have to request the aggregations you want. That can't be right because if I was eBay and I had a catalogue with hundreds of possible attributes, all of which are searchable, then telling the search engine what facets I would like to search by would be unscalable.

I'm Using:

  • Elastic Search
  • PHP Elastica Client

I would expect to simply be able to call Elastica/ResultSet.php::getAggregations() on Line 194 here:

Point of reference:

Could someone please clarify what I need to do to achieve this?

In Elasticsearch, you have to explicitly mention which fields you want to aggregate upon. Why don't you implement a client side (client of Elasticsearch) logic of getting all the field names and build an Elasticsearch search request with aggregations for all those fields?