How to include child aggregations into parent results?

I've got the following parent/child mapping here:

{
  "mappings": {
    "parentBook": {
      "properties": {
        "ean": {
          "type": "keyword"
        },
        "title": {
          "type": "string"
        }
      }
    },
    "childBook": {
      "_parent": {
        "type": "parentBook" 
      },
      "properties": {
        "price": {
          "type": "float"
        },
        "condition": {
          "type": "string"
        },
        "quantity": {
          "type": "integer"
        }
      }
    }
  }
}

Then I have the following entries in the index:

parentBook

{
  "ean": "9783353002303",
  "title": "...any kind of a book..."
}

childrens for parent ean "9783353002303"

[
  {
    "price": "20",
    "condition": "new",
    "quantity": 3
  },
  {
    "price": "10",
    "condition": "used",
    "quantity": 1
  },
  {
    "price": "5",
    "condition": "used",
    "quantity": 1
  },
]

The goal is now to query for the parentBook with EAN, title, etc. and to get the results back like this:

EAN: 9783353002303
Title: ...any kind of a book...
   [1 offer new from 20 EUR]  [2 offers used from 5 EUR]

I would like to show the aggregated values (minimum price per condition and count of child docs) just below the parent record and I would also be able to paginate the results.

I've already read about the Top Hit Aggregation but I always need to paginate through my grouped results.

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