Grouping by similarity

Hi. I've faced with a challenge in elasticsearch. I have an index which has many similar documents. It can be detected by more like this query. So I wanted somehow group these similar documents during querying. For example, I search for documents by term and get two documents with similar titles. I want to get it grouped. As I know ES has filter aggregation, but unfortunately, I cannot use document field value there.
I need this because I want to filter out similar documents by the date they are posted(keep in hits only latest similar documents). Maybe I'm trying to go the wrong way and this can be implemented with a different solution? For example with custom scoring. Anyway, please help me with my problem. Thanks in advance!

I think you can use
Match_all phrase and group them

I do not understand how this query should looks like.

I know what query you suggest me to use. I don't know how to group by this query with document field as a param.

inplace of message use the field and provide it the term which you want to group

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