@Kimchy - Sort not working in nested query, Is this bug or missing feature

Query::

{
"query": {
"nested": {
"path": "guids_rated_fan_inverse",
"query": {
"term": {
"guids_rated_fan_inverse.guid": "34"
}
},
"sort": {
"guids_rated_fan_inverse.time_created": {
"order": "desc"
}
}
}
}
}

Data is::

guids_rated_fan_inverse: [

  • {
    • guid: 34
    • time_created: 1320479261
      }
  • {
    • guid: 600
    • time_created: 1320479635
      }

]

Thanks...

You can't sort on nested docs.

On Sat, Nov 5, 2011 at 9:54 AM, Narinder Kaur narinder.kaur@izap.in wrote:

Query::

{
"query": {
"nested": {
"path": "guids_rated_fan_inverse",
"query": {
"term": {
"guids_rated_fan_inverse.guid": "34"
}
},
"sort": {
"guids_rated_fan_inverse.time_created": {
"order": "desc"
}
}
}
}
}

Data is::

guids_rated_fan_inverse: [

  • {
    • guid: 34
    • time_created: 1320479261
      }
  • {
    • guid: 600
    • time_created: 1320479635
      }

]

Thanks...

Hmmm, Is there any other solution for this kind of problem ?

Why is it a problem? If you have multiple values for a field (which is what
nested docs are usually used for), then you can't really sort on that
field...

On Tue, Nov 8, 2011 at 6:46 AM, Carl Sharma carl@izap.in wrote:

Hmmm, Is there any other solution for this kind of problem ?

But In my case, It is unique against an unique array key

But the result is the "root" document, so based on what will it sort? We
can come up with saying something like the "highest" or "lowest" value of
all available values within the nested docs, but its not supported.

On Thu, Nov 10, 2011 at 12:38 PM, Narinder Kaur narinder.kaur@izap.inwrote:

But In my case, It is unique against an unique array key

That would be great! I am facing similar problem with documents:

{
"itemName": "foo",
"itemDescription": "bar",
"locations": [
{ "coordinates": { "lat": 50.12, "lon": 14.32] },
{ "coordinates": { "lat": 51.12, "lon": 14.88] }
]
}

Now I would like to implement use case to "search for the closest items". I
think being able to support such sorting will greatly improve the
flexibility. Does that make sense? Are there any future plans for this kind
of feature?

On Sunday, November 13, 2011 8:06:22 AM UTC+1, kimchy wrote:

But the result is the "root" document, so based on what will it sort? We
can come up with saying something like the "highest" or "lowest" value of
all available values within the nested docs, but its not supported.

On Thu, Nov 10, 2011 at 12:38 PM, Narinder Kaur <narind...@izap.in<javascript:>

wrote:

But In my case, It is unique against an unique array key

--

Yes, there are plans to support it. No dates though.

On Aug 13, 2012, at 4:27 PM, Pavel Horal horal.pavel@gmail.com wrote:

That would be great! I am facing similar problem with documents:

{
"itemName": "foo",
"itemDescription": "bar",
"locations": [
{ "coordinates": { "lat": 50.12, "lon": 14.32] },
{ "coordinates": { "lat": 51.12, "lon": 14.88] }
]
}

Now I would like to implement use case to "search for the closest items". I think being able to support such sorting will greatly improve the flexibility. Does that make sense? Are there any future plans for this kind of feature?

On Sunday, November 13, 2011 8:06:22 AM UTC+1, kimchy wrote:
But the result is the "root" document, so based on what will it sort? We can come up with saying something like the "highest" or "lowest" value of all available values within the nested docs, but its not supported.

On Thu, Nov 10, 2011 at 12:38 PM, Narinder Kaur narind...@izap.in wrote:
But In my case, It is unique against an unique array key

--

--