spokeypokey
unread,Dec 16, 2011, 5:41:03 PM12/16/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rav...@googlegroups.com
A couple of questions about paging through query results sets
when using documents with nested array structures:
1. I realize that when you query indexes constructed in the
following way, paging is straight-forward; you can use Skip().Take(),
since there are no SkippedResults:
public class NestedPropertyIndex1 : AbstractIndexCreationTask<Provider>
{
public NestedPropertyIndex1()
{
Map = providers =>
from p in providers
select new
{
p.Name,
p.Zip,
Categories_Name = p.Categories.Select(c => c.Name),
Categories_EffectiveFrom = p.Categories.Select(c => c.EffectiveFrom),
Categories_EffectiveThrough = p.Categories.Select(c => c.EffectiveThrough),
};
}
}
However, this indexing tactic isn't always appropriate. Sometimes it's necessary to create
an index in the following fashion due to querying requirements:
public class NestedPropertyIndex2 : AbstractIndexCreationTask<Provider>
{
public NestedPropertyIndex2()
{
Map = providers =>
from p in providers
from c in p.Categories
select new
{
p.Name,
p.Zip,
Categories_Name = c.Name,
Categories_EffectiveFrom = c.EffectiveFrom,
Categories_EffectiveThrough = c.EffectiveThrough,
};
}
}
For example, given the following query:
var result = (from p in session.Query<Provider, NestedPropertyIndex2>()
where p.Categories.Any(c => c.Name == "Category1" && c.EffectiveFrom < new DateTime(2011, 1, 2))
select p).ToArray();
it's necessary to use NestedPropertyIndex2 due to the fact that BOTH the Category Name
AND EffectiveFrom date from from a single child object need to match the query constraints.
It isn't valid to match the Category Name from one child object and the Category EffectiveDate
from a different child object, which can happen if you use NestedPropertyIndex1.
Which leads my to my real question:
When you query using NestedPropertyIndex2, you invariably get "SkippedResults".
After having reviewed Ayende's "IndexQueryOperation" code, it seems to me that
the only paging navigation I can reliably do (without using estimation logic and
trial and error searches) is:
- Get the first page of results
- Get the next page of results.
There doesn't seem to be any reliable way of doing either of the following:
- Get any previous page of results (assuming the previous page is not the first page)
- Get any succeeding page that is not the next page.
What I am looking for is confirmation as to whether I need to abandon true, simple paging
when using an index like NestedPropertyIndex2.