function searchIndex(sQuery, oOptions) {

		oOptions || (oOptions = {});

		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();
				aSearchResults = formatResult(aSearchResults, sQuery, oOptions);

				resolve({
					success: aSearchResults.data && !!(aSearchResults.data.length),
					totalHits: aSearchResults.data && aSearchResults.data.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
@param sQuery, the search string
@returns {Promise}
Searches the index given a search string @param sQuery the search string @returns { Promise }
function searchIndex(sQuery, oOptions) {
		oOptions || (oOptions = {});
		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);
				}
				searchByField("title", sQuery);
				METADATA_FIELDS.forEach(function(sField) {
					lunr.tokenizer(sQuery).forEach(function(sSubQuery) {
						searchByField(sField, sSubQuery, true);
					});
				});
				searchByField("paramTypes", sQuery);
				searchByField("contents", sQuery);
				aSearchResults = oSearchResultsCollector.getAll();
				aSearchResults = formatResult(aSearchResults, sQuery, oOptions);
				resolve({
					success: aSearchResults.data && !!(aSearchResults.data.length),
					totalHits: aSearchResults.data && aSearchResults.data.length,
					matches: aSearchResults
				});
			});
		});
	}
function searchIndex ( sQuery , oOptions ) { oOptions || ( oOptions = { } ) ; 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 ) ; } searchByField ( "title" , sQuery ) ; METADATA_FIELDS . forEach ( function ( sField ) { lunr . tokenizer ( sQuery ) . forEach ( function ( sSubQuery ) { searchByField ( sField , sSubQuery , true ) ; } ) ; } ) ; searchByField ( "paramTypes" , sQuery ) ; searchByField ( "contents" , sQuery ) ; aSearchResults = oSearchResultsCollector . getAll ( ) ; aSearchResults = formatResult ( aSearchResults , sQuery , oOptions ) ; resolve ( { success : aSearchResults . data && ! ! ( aSearchResults . data . length ) , totalHits : aSearchResults . data && aSearchResults . data . 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 @param sQuery the search string @returns { Promise<any > }
// search by fields in priority order // collect all results