We would like to show the average value of a number column that is part of the search results inside a facet.

The result would then be that the facet, besided a #count attribute, also gets a #average attribute.

We could then use that average in, for example, this facetapi_graph widget we are working on.

What would be the best approach to implement this?

Comments

batje’s picture

I came across this page (for Solr) that pretty much describes that (at least) Solr can do exactly this.

That page also describes these statistics can be loaded on a field within a query basis. There is also an issue for this in the search_api queue.

batje’s picture

Issue summary: View changes

Used the phrasing for the issue in the search_api issue queue

NWOM’s picture

Title: Show average of Number column » Aggregate by Average
Component: Custom Search Blocks » Code
Issue summary: View changes

Aggregating by Average would be incredibly beneficial for the project I'm working on right now as an example.

NWOM’s picture

Title: Aggregate by Average » Aggregate by Average/Mean