$(function() {	
	
	$( "#textToSearch" ).autocomplete({
		source: function(request, response) {
			var results = $.ui.autocomplete.filter(keyWordArray, request.term);
			response(results.slice(0, 10));
		},
		minLength:1
	});	
	
	// Overrides the default auto complete filter function to search only from the beginning of the string
    $.ui.autocomplete.filter = function (array, term) {
        var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(term), "i");	
		
        return $.grep(array, function (value) {
            return matcher.test(value.label || value.value || value);
        });
    };
	
});