The top hits aggregation is quite a powerful feature of Elasticsearch. The aggregation support is a step closer to get this functionality, but it would be awesome to make these top hits reactive and as a built it feature.
var cursor = index.search('test');
// get all aggregations
var types = cursor.getTophitsTypes();
types.forEach(function (type) {
var tophits = cursor.getTophits(type);
console.log(tophits.fetch());
})
looks cool for me! would be awesome to have the logic for the tophits implemented in an ElasticsearchCursor so that we don't have to adjust code in the core package unnecessarily.
The top hits aggregation is quite a powerful feature of Elasticsearch. The aggregation support is a step closer to get this functionality, but it would be awesome to make these top hits reactive and as a built it feature.
Example:
This would generate tophits for 5 of the most popular categories. This would result in an ES aggregation that looks like:
The tophits can then be retrieved by:
I'd like some feedback on this 😄