Querying in a subset

Hey guys here's an example of what I'm doing and what I want to do.

I'm getting the first document, the last document and the total count of elements in an aggregation , but we're not able to filter over those specific documents (first and last). Adding a filter to the base query will consider all the documents in the aggregation and it won't work because it will change our first and last document based in the filter.

Here's an example of the scenario.

Term aggregation By 'x' returns 3 documents.

D1 { x: '5', fx: 'A', date: '2017-01-01T00:00:00' }
D2 { x: '5', fx: 'B', date: '2017-01-05T00:00:00' }
D3 { x: '5', fx: 'C', date: '2017-01-11T00:00:00' }

What we've now aggregating by 'x' is

Count:
    3
First: 
    D1 { x: '5', fx: 'A', date: '2017-01-01T00:00:00' }
Last:
    D3 { x: '5', fx:'C', date: '2017-01-013T00:00:00' }

What we want to do

Filter by whatever field in D1 or D3 i.e. D1.fx is equals to 'A'. If yes, return bucket, If not, don't return

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