Sort seems to be ignored when filter contains a query on parent field

Hi,

I have the following query:
{
"query": {
"bool": {
"must": {
"has_parent": {
"type": "premises",
"score_mode": "score",
"query": {
"bool": {
"must": {
"match": {
"street": {
"query": "Generaal jacques",
"minimum_should_match": "70%"
}
},
"filter": {
"bool": {
"must": [
{
"term": {
"backyard": "S"
}
},
{
"term": {
"status_published": 1
}
},
{
"term": {
"status_visible": 1
}
},
{
"term": {
"status_approved": 1
}
}
]
}
}
}
}
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"rent_basic": {
"gte": "200",
"lte": "600"
}
}
},
{
"nested": {
"path": "period",
"score_mode": "none",
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"term": {
"period.available": 1
}
},
{
"range": {
"period.start": {
"lte": 1505433601
}
}
},
{
"range": {
"period.end": {
"gte": 1497129105
}
}
}
]
}
}
}
}
}
},
{
"term": {
"status_published": 1
}
},
{
"term": {
"status_visible": 1
}
},
{
"term": {
"status_approved": 1
}
}
]
}
}
}
}
},
"sort": [
"_score",
{
"surface_area": "desc"
}
],
"size": 10,
"_source": false
}

The sort seems to be completely ignored, and I can't figure out why, as it sorts on a field of the child which we are querying. In short: the query looks for rooms that match certain criteria (filter) and for which the parent (the premises in which the room is housed) address matches the search term.

Any idea what could cause this? Or how should I understand this? Are there solutions?

Kind regards

pieter

ok, some stupid, obvious mistake could be the sort on _score. However, even when removing that, and purely sorting on surface area doesn't seem to work.

In case you wonder (some stuff seems to be defined differently these days), my query is written voor ES 2.3

Kind regards

Pieter

Found out that when adding the sort to the url as a query string parameter, it works!

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