Displaying documents in result multiple times with sorting

Let's say that a nested document about a person can store data of type birthData, deathData, etc. We want to get ES documents sorted by [MONTH-DAY DESC], [YEAR ASC].

Filtering and sorting by a single event type is a piece of cake, but what if I want to sort by multiple event dates and display a document as many times as there are dates inside? As we have several millions of docs, and multiple event types, result manipulaton on application server would be a no-go

Short example:

{
        "id": "ID1",
        "fullName": "John Smith",
        "eventsData": [
          {
            "event_data_type": "BD",
            "event_date": "1971-12-30T00:00:00Z",
          },
          {
            "event_data_type": "DD",
            "event_date": "2013-02-11T00:00:00Z",
          }
        ]
    },
    {
        "id": "ID2",
        "fullName": "Jake Smith",
        "eventsData": [
          {
            "event_data_type": "BD",
            "event_date": "1965-02-02T00:00:00Z",
          },
          {
            "event_data_type": "DD",
            "event_date": "2011-12-30T00:00:00Z",
          }
        ]
    }

The printed results with relevant data would be:

   ID1, BD, 1971-12-30
   ID2, DD, 2011-12-30
   ID1, DD, 2013-02-11
   ID2, BD, 1965-02-02

So if a document has n events, then it is displayed n times.

Can you offer any elastic search solution for this problem? What feature should we use?

you have to index each event as an individual document to make that happen IMO

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