public void WheQuery_CanOrderByNestedProperty() { using (GetNewServer()) using (var store = new DocumentStore { Url = "http://localhost:8079" }) { store.Initialize(); using (IDocumentSession s = store.OpenSession()) { for (int i = 0; i < 10; i++) { s.Store(new { Id = "samples/" + i, Name = "Sample" + i, Body = new { Order = i, Inserted = SystemTime.Now.AddDays(i) } }); } s.SaveChanges(); } using (IDocumentSession s = store.OpenSession()) { IDocumentQuery <dynamic> query = s.Advanced.LuceneQuery <dynamic>() .WhereBetweenOrEqual("Body.Inserted", SystemTime.Now.Date, SystemTime.Now.AddDays(2)) .OrderBy("-Body.Order") .Take(2) .WaitForNonStaleResults(); var objects = query.ToArray(); Assert.Equal(2, objects.Length); Assert.Equal(3, query.QueryResult.TotalResults); Assert.Equal(2, objects[0].Body.Order); } } }