私はユーザーの検索クエリをelasticsearchインデックスに追加してオートコンプリートを試みています。ユーザークエリのインデックス
私はsearchServiceでこのようなESのためのJS APIを使用しています:
this.indexQuery = function (searchTerms) {
var userQueries = es_return.hits.hits;
esClient.index({
index: 'query-index1',
type: 'autocomplete',
body: {
fields: ['suggestions']
}
}).then(function(es_return) {
userQueries.push(searchTerms);
}, function(error) {
console.log(error);
});
};//eof indexQuery
これは、ユーザーを追加する必要がありますが、右、検索のための提出の「インデックス」にクエリを入力しましたか?私<form>
と<button>
要素で
、私は私のコントローラでng-submit="vm.search(); vm.indexQuery()"
とindexQueryを持って次のようになります。
vm.indexQuery = function(searchTerms) {
$http.post('localhost:9200/query-index1/autocomplete', {
params: {
suggestions: vm.searchTerms
}
}).then (function(response){
console.log("success");
}, function(error) {
console.log("error");
});
};
};
しかし、それだけで働いていません。どこが間違っていますか?
'ng-keydown =" indexQuery($ event) "' - 'vm.indexQuery'の' searchTerms'パラメタに何も渡されていないように見えます。あなたの 'ng-model'入力が何であっても – plong0
このリンクを参照することができますhttps://github.com/vhvinod/AngularJS-ElasticSearch –
@ plong0、okありがとう – user3125823