I have a problem on selecting the distinct data based on the name:
The problem is
In a Table which contains the following data:
ID Name Age
1 Abc 22
2 cbc 20
3 Abc 22
4 ccc 21
5 Abc 22
If it is a MySQL Database.. We can select the distinct value by
SELECT * FROM Table GROUP BY Name;
First, the query that you are using here is a MySQL "feature" (read
"bug"). You are grouping by name, but not telling the database what to
do with the ungrouped columns.
So it should read something like this (depending on what you actually
want):
SELECT Name, min(ID), min(Age) from Table GROUP BY Name.
The Elasticsearch equivalent is called "facets"
and the particular facet that you should use depends on what other data
you need.
For instance, for just distinct terms, look at the terms facet:
If you need to group on one field and process another numeric field,
have a look at the terms stats facet:
etc
clint
Is there any alternative in elasticsearch to select the Distinct
Value so we get the output as
I have a problem on selecting the distinct data based on the name:
The problem is
In a Table which contains the following data:
ID Name Age
1 Abc 22
2 cbc 20
3 Abc 22
4 ccc 21
5 Abc 22
If it is a MySQL Database.. We can select the distinct value by
SELECT * FROM Table GROUP BY Name;
First, the query that you are using here is a MySQL "feature" (read
"bug"). You are grouping by name, but not telling the database what to
do with the ungrouped columns.
So it should read something like this (depending on what you actually
want):
SELECT Name, min(ID), min(Age) from Table GROUP BY Name.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.