i'm using :
AngularJs : AngularJS v1.2.22
Bootstrap : Bootstrap v3.1.1 + ui-bootstrap-tpls-0.11.0.js
Elasticsearch.angular : elasticsearch - v2.4.0 - 2014-07-30
I work on a front end with angular and i want to make an autocompleted input using twitter-bootstap typeahead on an elasticsearch document. I can query elasticsearch with angularJs and get the data correctly (by putting them in the scope) but when i try an asynchrone query it failed with an error **"Error: matches is undefined" ( full error her : http://pastebin.com/CJSubYbp )
In angularjs, service for elasticsearch :
interfaceApp.service('elasticQuery', function (esFactory) {
return esFactory({ host: 'localhost:9200' });
});
my controller : 'use strict';
/* Controllers */
var searchSimpleModules = angular.module('searchSimpleModules', ['ngRoute']);
searchSimpleModules.controller('searchSimpleCtrl', function ($scope, $rootScope, $routeParams, $location, elasticQuery) {
$scope.simplequery = "";
$scope.autocomplete = function(value) {
$scope.simplequery = value;
var index_p = 'donnees';
var size_p = 50;
var body_p = {
"query": {
"query_string": { "query" : value +"*" }
}
};
elasticQuery.search({
index: index_p,
size: size_p,
body: body_p
}).then(function (response) {
$scope.hits= response.hits.hits;
});
};
$scope.find = function () {
elasticQuery.search({
index: 'donnees',
size: 50,
body: { "query": { "query_string": { "query" : "P000023*" } } }
}).then(function (response) {
$scope.hits= response.hits.hits;
});
};
});
the html input:
<input required type="text"
popover="Rechercher un terme sur toute la partie {{simplesearch.domaine}}.Il est possible d'utiliser des *,? et double quote."
popover-trigger="focus"
placeholder="recherche globale"
class="form-control"
typeahead="entree for entree in autocomplete($viewValue)"
ng-model="simplequery"
>
In the firebug console i see that i get the error before the "http.get()" made by the service.
I make many search to debug this but i can't get out of it.
Any advice are welcomed. thanks Best regards