function searchIndex(sQuery) {

		sQuery = preprocessQuery(sQuery);

		return new Promise(function(resolve, reject) {

			fetchIndex().then(function(oIndex) {

				var aSearchResults,
					oSearchResultsCollector = new SearchResultCollector();

				function searchByField(sFieldToSearch, sSubQuery, bReturnMatchedDocWord) {

					var aResults = oIndex.search(sSubQuery, createSearchConfig(sFieldToSearch));

					oSearchResultsCollector.add(aResults,
						sSubQuery,
						sFieldToSearch,
						bReturnMatchedDocWord);
				}

				// search by fields in priority order
				searchByField("title", sQuery);
				METADATA_FIELDS.forEach(function(sField) {
					lunr.tokenizer(sQuery).forEach(function(sSubQuery) {
						searchByField(sField, sSubQuery, true);
					});
				});
				searchByField("paramTypes", sQuery);
				searchByField("contents", sQuery);

				// collect all results
				aSearchResults = oSearchResultsCollector.getAll();


				resolve({
					success: !!(aSearchResults.length),
					totalHits: aSearchResults.length,
					matches: aSearchResults
				});
			});
		});
	}
function searchIndex(sQuery) {

		sQuery = preprocessQuery(sQuery);

		return new Promise(function(resolve, reject) {

			fetchIndex().then(function(oIndex) {

				var aSearchResults,
					oSearchResultsCollector = new SearchResultCollector();

				function searchByField(sFieldToSearch, sSubQuery, bReturnMatchedDocWord) {

					var aResults = oIndex.search(sSubQuery, createSearchConfig(sFieldToSearch));

					oSearchResultsCollector.add(aResults,
						sSubQuery,
						sFieldToSearch,
						bReturnMatchedDocWord);
				}

				// search by fields in priority order
				searchByField("title", sQuery);
				METADATA_FIELDS.forEach(function(sField) {
					lunr.tokenizer(sQuery).forEach(function(sSubQuery) {
						searchByField(sField, sSubQuery, true);
					});
				});
				searchByField("paramTypes", sQuery);
				searchByField("contents", sQuery);

				// collect all results
				aSearchResults = oSearchResultsCollector.getAll();


				resolve({
					success: !!(aSearchResults.length),
					totalHits: aSearchResults.length,
					matches: aSearchResults
				});
			});
		});
	}
function searchIndex ( sQuery ) { sQuery = preprocessQuery ( sQuery ) ; return new Promise ( function ( resolve , reject ) { fetchIndex ( ) . then ( function ( oIndex ) { var aSearchResults , oSearchResultsCollector = new SearchResultCollector ( ) ; function searchByField ( sFieldToSearch , sSubQuery , bReturnMatchedDocWord ) { var aResults = oIndex . search ( sSubQuery , createSearchConfig ( sFieldToSearch ) ) ; oSearchResultsCollector . add ( aResults , sSubQuery , sFieldToSearch , bReturnMatchedDocWord ) ; } // search by fields in priority order searchByField ( "title" , sQuery ) ; METADATA_FIELDS . forEach ( function ( sField ) { lunr . tokenizer ( sQuery ) . forEach ( function ( sSubQuery ) { searchByField ( sField , sSubQuery , true ) ; } ) ; } ) ; searchByField ( "paramTypes" , sQuery ) ; searchByField ( "contents" , sQuery ) ; // collect all results aSearchResults = oSearchResultsCollector . getAll ( ) ; resolve ( { success : ! ! ( aSearchResults . length ) , totalHits : aSearchResults . length , matches : aSearchResults } ) ; } ) ; } ) ; }
Searches the index, given a search string

@param sQuery, the search string
@returns {Promise<any>}
Searches the index given a search string
Search the index using the given query