Aggregation count of mail domains using elastisearch

I have following documents in my index:

{
    "name":"rakesh"
    "age":"26"
    "email":"rakesh@gmail.com"
}

{
    "name":"sam"
    "age":"24"
    "email":"samjoe@elastic.com"
}

{
    "name":"joseph"
    "age":"26"
    "email":"joseph@gmail.com"
}

{
    "name":"genny"
    "age":"24"
    "email":"genny@hotmail.com"
}

Now i need to get the count of all mail domains. Like:

@gmail.com:2,
@hotmail.com:1,
@elastic.com:1

using elastic search aggregations.

I already have an existing data in my index. so i cannot able to use the analyzers over it. can able to find the records which matches the given query. But i need have a count of each domain.

Thanks in advance for your help.

May be using something like https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-simplepattern-tokenizer.html would help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.