How to use the lunr.Index 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 veteransaffairscanada / vac-benefits-directory / selectors / benefits_B.js View on Github external
(
    patronFilter,
    serviceFilter,
    statusFilter,
    healthIssueFilter,
    selectedNeeds,
    benefits,
    needs,
    eligibilityPaths,
    searchString,
    currentLanguage,
    enIdx,
    frIdx
  ) => {
    // Reinitalize indexes after they are serialized by Redux
    enIdx = lunr.Index.load(JSON.parse(enIdx));
    frIdx = lunr.Index.load(JSON.parse(frIdx));

    let selectedEligibility = {
      patronType: patronFilter,
      serviceType: serviceFilter,
      statusAndVitals: statusFilter,
      serviceHealthIssue: healthIssueFilter
    };
    let eligibilityMatch = (path, selected) => {
      let matches = true;
      [
        "serviceType",
        "patronType",
        "statusAndVitals",
        "serviceHealthIssue"
      ].forEach(criteria => {
github AwesomeLogos / awesome-logos / src / search.ts View on Github external
function init(logger:Pino.Logger) {


    searchIndex = new lunr.Index;

    searchIndex.ref('index');
    searchIndex.field('name');

    const dataSources = sources.getSources();
    for (let dataLoop = 0; dataLoop < dataSources.length; dataLoop++)
    {
        const images = dataSources[dataLoop].images;

        for (let imageLoop = 0; imageLoop < images.length; imageLoop++) {
            searchIndex.add({index: `${dataLoop}:${imageLoop}`, name: images[imageLoop].name});
            imageCount += 1;
        }
    }

    logger.info({ imageCount }, "Images indexed");
github bvaughn / js-worker-search / benchmarks / search.js View on Github external
function setupTest() {
  lunrJsIndex = new lunr.Index();
  lunrJsIndex.field("title");
  lunrJsIndex.field("author");
  lunrJsIndex.ref("isbn");
  for (var i = 0, length = books.length; i < length; i++) {
    lunrJsIndex.add(books[i]);
  }

  searchLatest = buildIndex(JsSearchLatest);
  searchLocal = buildIndex(JsSearchLocal);

  runTests();
}
github angeloashmore / react-lunr / src / Lunr.js View on Github external
constructor(props) {
    super(props)

    this.state = {
      query: props.initialQuery,
    }

    this.index =
      typeof props.index === 'string'
        ? lunr.Index.load(JSON.parse(props.index))
        : props.index

    this.store =
      typeof props.store === 'string' ? JSON.parse(props.store) : props.store
  }
github veteransaffairscanada / vac-benefits-directory / components / search.js View on Github external
constructor(props) {
    super(props);
    this.enIdx = lunr.Index.load(JSON.parse(this.props.enIdx));
    this.frIdx = lunr.Index.load(JSON.parse(this.props.frIdx));
  }
github Soluto / tweek / services / editor / service-worker / src / search.js View on Github external
async function getIndex() {
  const response = await fetch(urls.SEARCH_INDEX, { credentials: 'include' });
  const serializedIndex = await response.json();
  searchIndex = lunr.Index.load(serializedIndex);
  return searchIndex;
}
github bvaughn / js-worker-search / benchmarks / create-index.js View on Github external
.add("lunr", () => {
      var lunrJsIndex = new lunr.Index();
      lunrJsIndex.field("title");
      lunrJsIndex.field("author");
      lunrJsIndex.ref("isbn");
      for (var i = 0, length = books.length; i < length; i++) {
        lunrJsIndex.add(books[i]);
      }
    })
    .add("js-worker-search:latest", () => {
github bvaughn / js-search / benchmarks / search.js View on Github external
function setupTest() {
  lunrJsIndex = new lunr.Index();
  lunrJsIndex.field('title');
  lunrJsIndex.field('author');
  lunrJsIndex.ref('isbn');
  for (var i = 0, length = books.length; i < length; i++) {
    lunrJsIndex.add(books[i]);
  }

  searchLatest = buildIndex(JsSearchLatest.Search, JsSearchLatest.UnorderedSearchIndex);
  searchLatestTfIdf = buildIndex(JsSearchLatest.Search, JsSearchLatest.TfIdfSearchIndex);
  searchLocal = buildIndex(JsSearchLocal.Search, JsSearchLocal.UnorderedSearchIndex);
  searchLocalTfIdf = buildIndex(JsSearchLocal.Search, JsSearchLocal.TfIdfSearchIndex);

  runTests();
}