<commit_before>'use strict';

/* eslint-env worker */
/* global importScripts, lunr */

var SEARCH_TERMS_URL = '/generated/docs/app/search-data.json';

// NOTE: This needs to be kept in sync with `ngsw-config.json`.
importScripts('/assets/js/lunr.min.js');

var index;
var pages /* : SearchInfo */ = {};

// interface SearchInfo {
//  [key: string]: PageInfo;
// }

// interface PageInfo {
//   path: string;
//   type: string,
//   titleWords: string;
//   keyWords: string;
// }

self.onmessage = handleMessage;

// Create the lunr index - the docs should be an array of objects, each object containing
// the path and search terms for a page
function createIndex(addFn) {
  return lunr(/** @this */function() {
    this.ref('path');
    this.field('titleWords', {boost: 100});
    this.field('headingWords', {boost: 50});
    this.field('members', {boost: 40});
    this.field('keywords', {boost: 20});
    addFn(this);
  });
}

// The worker receives a message to load the index and to query the index
function handleMessage(message) {<commit_msg>fix(docs-app): remove stopWordFilter from lunr pipeline (#4536)<commit_after>'use strict';

/* eslint-env worker */
/* global importScripts, lunr */

var SEARCH_TERMS_URL = '/generated/docs/app/search-data.json';

// NOTE: This needs to be kept in sync with `ngsw-config.json`.
importScripts('/assets/js/lunr.min.js');

var index;
var pages /* : SearchInfo */ = {};

// interface SearchInfo {
//  [key: string]: PageInfo;
// }

// interface PageInfo {
//   path: string;
//   type: string,
//   titleWords: string;
//   keyWords: string;
// }

self.onmessage = handleMessage;

// Create the lunr index - the docs should be an array of objects, each object containing
// the path and search terms for a page
function createIndex(addFn) {
  return lunr(/** @this */function() {
    this.pipeline.remove(lunr.stopWordFilter);
    this.ref('path');
    this.field('titleWords', {boost: 100});
    this.field('headingWords', {boost: 50});
    this.field('members', {boost: 40});
    this.field('keywords', {boost: 20});
    addFn(this);
  });
}

// The worker receives a message to load the index and to query the index
function handleMessage(message) {
{'fraction_non_alphanumeric': 0.15961800818553887, 'fraction_numerical': 0.010004547521600727, 'mean_word_length': 3.489795918367347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4726415', 'n_tokens_mistral': 727, 'n_tokens_neox': 693, 'n_words': 211}