projects/ngrx.io/src/app/search/search-worker.js
function queryIndex(query) {
  try {
    if (query.length) {
      var results = index.search(query);
      if (results.length === 0) {
        // Add a relaxed search in the title for the first word in the query
        // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
        var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
        results = index.search(query + ' ' + titleQuery);
      }
      // Map the hits into info about each page to be returned as results
      return results.map(function(hit) { return pages[hit.ref]; });
    }
  } catch(e) {
    // If the search query cannot be parsed the index throws an error
    // Log it and recover
    console.log(e);
  }
  return [];
}
function queryIndex(query) {
  try {
    if (query.length) {
      var results = index.search(query);
      if (results.length === 0) {
        // Add a relaxed search in the title for the first word in the query
        // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
        var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
        results = index.search(query + ' ' + titleQuery);
      }
      // Map the hits into info about each page to be returned as results
      return results.map(function(hit) { return pages[hit.ref]; });
    }
  } catch(e) {
    // If the search query cannot be parsed the index throws an error
    // Log it and recover
    console.log(e);
  }
  return [];
}
function queryIndex ( query ) { try { if ( query . length ) { var results = index . search ( query ) ; if ( results . length === 0 ) { // Add a relaxed search in the title for the first word in the query // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*" var titleQuery = 'titleWords:*' + query . split ( ' ' , 1 ) [ 0 ] + '*' ; results = index . search ( query + ' ' + titleQuery ) ; } // Map the hits into info about each page to be returned as results return results . map ( function ( hit ) { return pages [ hit . ref ] ; } ) ; } } catch ( e ) { // If the search query cannot be parsed the index throws an error // Log it and recover console . log ( e ) ; } return [ ] ; }
Query the index and return the processed results
Query the index and return the processed results