how to improve search?
var partial_highlighter = function (item) {
var search_query = this.query;
var query_contains_space = this.query.toLowerCase().indexOf(" ");if (query_contains_space <= 0) {
var query = search_query.replace(/[-[]{}()*+?.,\^$|#s]/g, '\$&');
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + '';
});
} else {
var splited = search_query.toLowerCase().split(" ");
$.each( splited, function( index, value ){
var query = value.replace(/[-[]{}()*+?.,\^$|#s]/g, '\$&');
item = item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + '';
});
});
return item;
}
};var partial_matcher = function (item) {
var search_query = this.query;
var query_contains_space = this.query.toLowerCase().indexOf(" ");if (query_contains_space <= 0) {
var query = search_query.replace(/[-[]{}()*+?.,\^$|#s]/g, '\$&');
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + '';
});
} else {
var splited = search_query.toLowerCase().split(" ");
$.each( splited, function( index, value ){
var query = value.replace(/[-[]{}()*+?.,\^$|#s]/g, '\$&');
item = item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + '';
});
});
return item;
}
};$.fn.typeahead.Constructor.prototype.highlighter = partial_highlighter;
$.fn.typeahead.Constructor.prototype.matcher = partial_matcher;