Aggregation with additional document fields? (Like a SQL inner join to nested group by)

Thanks in advance for any help with achieving our goal or on the terminology I may use to find an example in Elasticsearch documentation and/or forum.

When performing a Max Terms aggregation to get the date of the newest doc for each specified doc field, how would we also bring back other field values for each document?

In SQL you would perform an INNER JOIN against the table to bring back the row that matches the GROUP BY aggregated maximum.

e.g.

SELECT one, two, three, four FROM
(SELECT one, max(four) AS MaxTime
FROM mytable GROUP BY one) AS agg
INNER JOIN mytable AS mt
ON mt.one = agg.one AND mt.four = agg.MaxTime

How do you achieve this in Elasticsearch please?
We have the aggregation for the nested group by working, we just aren't sure how to also get the additional properties back at the same time.

(Examples using NEST C# would be awesome, thank you, but knowing how to achieve in JSON/Kibana would hopefully point us in the right direction too.)

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