How to aggregate query result in elasticsearch -


i new in elasticsearch. want elasticsearch result following sql query,

select distinct(car_name) car_master car_name '%suv%' 

i getting result doing:

{ "query": {     "query_string": {     "fields" : ["car_name"],     "query": "*suv*"     }   } } 

but want distinct records.

you there, need add terms aggregation on car_name field:

{    "query": {     "query_string": {     "fields" : ["car_name"],     "query": "*suv*"     }   },   "aggs": {     "cars": {       "terms": {         "field": "car_name"       }     }   } } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -