Hristo
Hristo

Reputation: 185

Sorting on nested Id property

Let's say we have a document like this

public class Event
{
    public string Id { get; set; }
    public EntityDescriptor Venue { get; set; }

    // Other properties omitted for simplicity
}

public class EntityDescriptor
{
    public string Id { get; set; }
    public string Name { get; set; }
}

And an index like this

public class Events : AbstractIndexCreationTask<Event>
{
    public Events()
    {
        Map = items => from e in items
                       select new
                       {
                           Venue_Id = e.Venue.Id,
                           Venue_Name = e.Venue.Name
                       };
    }
}

When trying to sort on Event.Venue.Id

session.Query<Event, Events>().Take(10).OrderBy(e => e.Venue.Id).ToArray();

the sent request is

/indexes/Events?&pageSize=10&sort=__document_id&SortHint-__document_id=String

Is this by design or a bug?

PS: OrderBy(e => e.Venue.Name) works as expected (sort=Venue_Name).

Upvotes: 0

Views: 65

Answers (1)

Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60021

It's not a bug. __document_id is the special known field containing the ID of the document. It's there regardless of whether you have an .Id property.

edit

I misread your question. This indeed appears to be a bug. I recommend you send a simple repro case to the Raven forum and let them know which RavenDB version you're using.

Upvotes: 1

Related Questions