src/fulltext.js
function(items, config) {

  config = config || {};
  config.searchableFields = config.searchableFields || [];
  this.items = items;
  // creating index
  this.idx = lunr(function () {
    // currently schema hardcoded
    this.field('name', { boost: 10 });

    var self = this;
    _.forEach(config.searchableFields, function(field) {
      self.field(field);
    });
    this.ref('id');
  })
  //var items2 = _.clone(items)
  var i = 1;
  _.map(items, (doc) => {

    if (!doc.id) {
      doc.id = i;
      ++i;
    }
    this.idx.add(doc)
  })

  this.store = _.mapKeys(items, (doc) => {
    return doc.id;
  })
}
function(items, config) {

  config = config || {};
  config.searchableFields = config.searchableFields || [];
  this.items = items;
  // creating index
  this.idx = lunr(function () {
    // currently schema hardcoded
    this.field('name', { boost: 10 });

    var self = this;
    _.forEach(config.searchableFields, function(field) {
      self.field(field);
    });
    this.ref('id');
  })
  //var items2 = _.clone(items)
  var i = 1;
  _.map(items, (doc) => {

    if (!doc.id) {
      doc.id = i;
      ++i;
    }
    this.idx.add(doc)
  })

  this.store = _.mapKeys(items, (doc) => {
    return doc.id;
  })
}
function ( items , config ) { config = config || { } ; config . searchableFields = config . searchableFields || [ ] ; this . items = items ; // creating index this . idx = lunr ( function ( ) { // currently schema hardcoded this . field ( 'name' , { boost : 10 } ) ; var self = this ; _ . forEach ( config . searchableFields , function ( field ) { self . field ( field ) ; } ) ; this . ref ( 'id' ) ; } ) //var items2 = _.clone(items) var i = 1 ; _ . map ( items , ( doc ) => { if ( ! doc . id ) { doc . id = i ; ++ i ; } this . idx . add ( doc ) } ) this . store = _ . mapKeys ( items , ( doc ) => { return doc . id ; } ) }
responsible for making full text searching on items
config provide only searchableFields
responsible for making full text searching on items config provide only searchableFields