How to get Distinct results using Search API

I have a "customer" index with fields "FirstName" and "LastName".

My index contains data as follows:
First Name | LastName
Richard | Lockwood
Richard | Lockwood 2
Richard | Lockwood 3
Richard | Lockwood 4
Richard | Lockwood 5
Richard | Lockwood 6

Will return 6 records, I want to return distinct records based on FirstName, which will return only one record. How can I do this?

Advance thanks for the response!

Hi @asimelastic

You can use Collapse search results.

@RabBit_BR Thank you so much for the reply.

I have found the solution and right approach to achieve this is using aggregations Aggregations | Elasticsearch Guide [8.8] | Elastic

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