itemsapi / itemsjs

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

Unnecessary override of the title property in the buckets creation #78

Closed vanch3d closed 3 years ago

vanch3d commented 3 years ago

The configuration for an aggregation defines a title property, such as:

{
  aggregations: {
    tags: {
      title: 'Tags',
      // conjunctive facet (AND)
      conjunction: true,
      // the default is 10
      size: 20
    },
    rating: {
      title: 'Actors',
      // non conjunctive facet (OR)
      conjunction: false,
      // it is sorting by value (not by count). 'count' is the default
      sort: 'term',
      order: 'asc',
      size: 5
    }
  }
}

I assumed it could be used for the UI part of the facets, once the search has been succesful. But the code for creating the buckets automatically generates a title property out of a humanised version of the id, see

https://github.com/itemsapi/itemsjs/blob/06e2e70812294e94b3759bf7fda47db4633ac765/src/helpers.js#L236-L241

return {      
    name: k,      
    title: aggregations[k].title || humanize(k),      
    position: position++,      
    buckets: buckets    
};
cigolpl commented 3 years ago

Hey @vanch3d, thanks for catching it. The title is not used anywhere else. Feel free to create a PR