Source: searchers/dataSearcher.js

 /** 
 *  
 * @class Searches a {Septima.Search.SearchableData}
 * @extends Septima.Search.Searcher
 * @constructs Septima.Search.DataSearcher
 * @param {Object} options DataSearcher expects these properties:
 * @param options.searchableData {Septima.Search.SearchableData} An object of type Septima.Search.SearchableData
 */
Septima.Search.DataSearcher = Septima.Class (Septima.Search.Searcher, /**  @lends Septima.Search.DataSearcher# */{
	/**
	 * This function is called when a result is selected.
	 * @callback Septima.Search.DataSearcher~selectCallback
	 * @param {Object} result
	 * @param result.title {string}
	 * @param result.description {string}
	 * @param result.data {object} The selected object
	 */

    initialize: function (options) {
    	this.Searcher(options);
    	this.searchableData = options.searchableData;
    },
        
    fetchData: function (query, caller) {
    	
        var queryResult = this.createQueryResult();
        
        var hits = this.searchableData.query(query.queryString);
        
        var count = hits.length;

        var listStrategy = this.getListStrategy(query, count);
		if (count > 0) {
			var description;
			if (listStrategy.show){
	    		for (var i=0;i<listStrategy.count;i++) {
	    			var hit = hits[i];
	    			var displayname = hit.title;
	    			if (listStrategy.isMixed){
	    				displayname += " (" +this.searchableData.singular + ")";
	    			}
	    			description = hit.description;
	    			var result1 = queryResult.addResult(displayname, description, " ", hit.object);
	    		}
			}else{
				description = null;
		        var result2 = queryResult.addNewQuery(this.searchableData.plural + " (" + count + ")", description, query.queryString, null, null);
			}
		}
    	setTimeout(Septima.bind(function (caller, queryResult){caller.fetchSuccess(queryResult);}, this, caller, queryResult), 100);
    },
    
    CLASS_NAME: 'Septima.Search.DataSearcher'

});