itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use
Apache License 2.0
350 stars 41 forks source link

[Question] How can I get the elements of an aggregation into a list? #122

Closed Kugeleis closed 1 year ago

Kugeleis commented 1 year ago

Say my aggregation price contains 10, 20, 30, 80. How can I get this into a list for further use like so
var myPrices = [10,20,30,80] ?

Kugeleis commented 1 year ago

I can patially answer my own question. This method (vue) works:

    valueList(agg) {
      var l = []
      this.searchResult.data.aggregations[agg].buckets.forEach(element => {

        l.push(Number(element.key));
        l.sort(function(a, b){return a - b});
      });
      console.log(agg,' list is ', l);
      return l
    }

A side effect is that itemsjs must be directed to calculate the aggregation of this facette and it will be displayed. Is there a way to prevent display e.g. have a silent aggegation calculated by itemsjs?