How to use the lunr.generateStopWordFilter function in lunr

To help you get started, we’ve selected a few lunr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Googer / Professor-Pine / app / gym.js View on Github external
buildIndex() {
    log.info('Splicing gym metadata and indexing gym data...');

    const gymsBase = require('PgP-Data/data/gyms'),
      gymsMetadata = require('PgP-Data/data/gyms-metadata'),
      mergedGyms = gymsBase
        .map(gym => Object.assign({}, gym, gymsMetadata[gym.gymId])),
      stopwordFilter = this.stopWordFilter,
      blacklistWordFilter = lunr.generateStopWordFilter(settings.blacklistWords);

    this.blacklistWordFilter = blacklistWordFilter;

    lunr.Pipeline.registerFunction(blacklistWordFilter, 'blacklistWords');
    lunr.Pipeline.registerFunction(stopwordFilter, 'customStopwords');

    this.gyms = new Map(mergedGyms
      .map(gym => [gym.gymId, gym]));

    this.regionMap = require('PgP-Data/data/region-map');
    this.regionGraph = require('PgP-Data/data/region-graph');

    this.index = lunr(function () {
      // reference will be the entire gym object so we can grab whatever we need from it (GPS coordinates, name, etc.)
      this.ref('object');
github Googer / Professor-Pine / app / gym.js View on Github external
return this.channelSearch(terms, nameOnly);
  }

  getGym(gymId) {
    for (let i = 0; i < this.gyms.length; i++) {
      let gym = this.gyms[i];
      if (gym.id === gymId) {
        return gym;
      }
    }
    return false;
  }

}

Gym.blacklistWordFilter = lunr.generateStopWordFilter(settings.blacklistWords);

module.exports = new GymCache();
github Googer / Professor-Pine / app / search.js View on Github external
usePipeline: false,
            boost: 10
          });
      }
      query.term(term,
        {
          fields: fields,
          usePipeline: false,
          boost: 1,
          editDistance: Math.floor(term.length / 4.5)
        });
    });
  }
}

Search.stopWordFilter = lunr.generateStopWordFilter([
  'a',
  'able',
  'about',
  'across',
  'after',
  'all',
  'almost',
  'also',
  'am',
  'among',
  'an',
  'and',
  'any',
  'are',
  'as',
  'at',