angularjs - elasticsearch run multiple different query in one call -



angularjs - elasticsearch run multiple different query in one call -

i want run 3 differents query (on same index) 1 phone call on elasticsearch service.

is possible ?

more elaborate question :

i create autocomplete function in angularjs search on 3 fields , display them : "t_family" + "t_genus" + "t_scientificname".

i making 1 query :

"query" : { "query_string" : { "query" : "t_family:" +value +" or t_genus:"+value+ " or t_scientificname:"+value} } // value user input , can contain wildcard *

but not revelant results.

now want create 3 different query , sort each 1 score. , 3 results , merge them in array , sort score (i addkeyword() function).

var keywords = []; keywords.push(val); $scope.ishide.logo=true; homecoming elasticquery.search({ index: $scope.domaine, size: 20, _source: false, body: { "fields" : ["t_family","t_genus","t_scientificname"], "query": { "bool" : {"must" : [{"wildcard" : { "t_family" : val }}]}}, "sort" : { "_score" : "desc" } } }).then(function (response){ addkeyword(response,keywords); homecoming elasticquery.search({ index: $scope.domaine, size: 20, _source: false, body: { "fields" : ["t_family","t_genus","t_scientificname"], "query": {"bool" : {"must" : [{"wildcard" : { "t_genus" : val }}]}}, "sort" : { "_score" : "desc" } } }).then(function (response) { addkeyword(response,keywords); homecoming elasticquery.search({ index: $scope.domaine, size: 20, _source: false, body: { "fields" : ["t_family","t_genus","t_scientificname"], "query": {"bool" : {"must" : [{"wildcard" : { "t_scientificname" : val }}]}}, "sort" : { "_score" : "desc" } } }).then(function (response) { addkeyword(response,keywords); homecoming keywords; }); homecoming keywords; }); });

i didn't find help create 3 imbricated phone call of elastichsearch in js code it's not best way maybe.

thanks

it possible run differents queries in elasticsearch "dis_max" :

return elasticquery.search({ index: $scope.domaine, size: 20, _source: false, body: { //"min_score" : 0.50, "fields" : ["t_family","t_genus","t_scientificname"], "highlight": {"pre_tags": ["<strong>"], "post_tags": ["</strong>"], "fields": { "t_family": {},"t_genus" : {}, "t_scientificname": {} }}, "query" : { "dis_max" : { "tie_breaker" : 0.0, "boost" : 1.0, "queries" : [ {"wildcard" : { "t_family" : val }}, {"wildcard" : { "t_genus" : val }}, {"wildcard" : { "t_scientificname" : val }} ] } }, "sort" : { "_score" : "desc" } } }).then(function (response){ homecoming addkeywords(response,keywords); });

angularjs elasticsearch

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -