Help with nested datatype or parent/child documents

I'm having a problem with organizing index, so I would appreciate your help.

My data is like this:

make    model     bodystyle    trim       package   price
Audi    A3        hatchback    1.6TDI     Package1  18000
Audi    A3        hatchback    2.0TDI     Package2  22000
Audi    A3        hatchback    3.0TSI     Package1  26000
Audi    A4        sedan        2.0TDI     Package1  30000
Audi    A4        sedan        3.0TDI     Package1  36000
BMW     3 Series  sedan        320i       Package1  33000
BMW     3 Series  sedan        330i       Package1  40000
BMW     5 Series  sedan        520d       Package1  38000
BMW     5 Series  sedan        530d       Package1  45000

I need to do a query for example package.price gte 15000 to have results like this (only show lowest price):

make    model      price
Audi    A3         18000
Audi    A4         30000
BMW     3 Series   33000
BMW     5 Series   38000

For query package.price gte 25000 this should be the result:

make    model      price
Audi    A3         26000  <--
Audi    A4         30000
BMW     3 Series   33000
BMW     5 Series   38000

Also, I need to sort results by make and price, asc or desc.

My first try is to make parent-child relation

PUT /baza2
{
  "mappings": {
    "make_model": {},
    "trim": {
      "_parent": {
        "type": "make_model"
      }
    },
    "package": {
      "_parent": {
        "type": "trim"
      }
    }
  }
}

When I query for package.price, I get results as I want, but one problem: I don't see price from nested document. How can I "pull" price to parent document?
I also have problem with sorting results by price.

I've tried with nested types, but I get duplicate results like:

Audi    A3     18000
Audi    A3     22000
Audi    A3     26000
Audi    A4     30000
Audi    A4     36000

If I "search" using aggregates, then I loose number of results, pagination, etc ...

Am I missing something ?

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