Alphanumeric sort on child field

Hi guys,
I'm using es5. I currently have a child-parent relations ship in same indice: prod
parent

{
  "prod": {
    "mappings": {
      "Parcel": {
        "properties": {
          "imported_date": {
            "type": "date"
          },
         ....
          "delivered_date": {
            "type": "date"
          },
          "parcel_org_dict": {
            "type": "object",
            "enabled": false
          },
        }
      }
    }
  }
}

and the child

{
  "prod": {
    "mappings": {
      "ParcelOrganization": {
        "_parent": {
          "type": "Parcel"
        },
        "_routing": {
          "required": true
        },
        "properties": {
          "carrier_reference": {
            "type": "keyword"
          },
          "organization_id": {
            "type": "integer"
          },

        }
      }
    }
  }
}

My query on Parent:

{
  "sort": [
    {
      "imported_date": "asc"
    }
  ],
  "query": {
    "bool": {
      "must": [
        {
          "has_child": {
            "query": {
              "terms": {
                "organization_id": [
                  949
                ]
              }
            },
            "inner_hits": {},
            "type": "ParcelOrganization"
            
          }
        },
        {
          "bool": {
            "should": []
          }
        }
      ]
    }
  },
  "from": 0,
  "size": 25
}

It is sorted by the field imported_date of the parent, very simple.
Now I want to sort by carrier_reference using asc, or desc But dont know where to start.
I did read about
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-weight
and
https://gist.github.com/matthiasg/2b8748cfdf919ce77c3fd0438613cee6
Was my approach doable? Can I combine sort by child field and parent field?
Thanks

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