itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unnecessary override of the title property in the buckets creation

vanch3d opened this issue · comments

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

itemsjs/src/helpers.js

Lines 236 to 241 in 06e2e70

return {
name: k,
title: humanize(k),
position: position++,
buckets: buckets
};

  • Is title used anywhere else in the code or by other integrations?
  • Would it make sense to use the humanised version only is the title has not been defined in the configuration, e.g.
return {      
    name: k,      
    title: aggregations[k].title || humanize(k),      
    position: position++,      
    buckets: buckets    
};

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