Hello,
I've been reading a lot about this topic because I've seen it has been asked before but I can do it works yet.
I am trying to get unique values from an index.
I have something like this:
id | app_name | url
1 | app_1 | https://subdomain.app_1.com
2 | app_1 | https://app_1.com
3 | app_2 | https://app_1.com
4 | app_3 | https://subdomain.app_3.com
5 | app_1 | https://app_3.com
I would like to receive just the distinct app_name:
app_1
app_2
app_3
The query I tried with aggs is:
GET app_index/_search
{
"aggs": {
"unique_apps": {
"terms": {
"field": "app_name",
}
}
}
}
I also tried a kind of group by here:
GET app_index/_search
{
"aggs": {
"unique_apps": {
"terms": {
"field": "app_name.keyword"
},
"aggs": {
"oneRecord": {
"top_hits": {
"size": 1
}
}
}
}
}
}
But I still receive all the apps.
- Is there a way to receive unique values?
- Maybe is there a possibility to check in
logstashif some value exists in the database and avoid sending it again? Or maybe use thefingerprintplugin and generate an unique_idaccording to the value of the field? If I receive the same information in that field it could generate the same ID so it won't be saved again.
I also checked if there's any possibility to create unique fields in Elasticsearch but I see it's not possible.
Thank you very much for your help and time ![]()