> Marcel Reutegger wrote:
> Hi Helio,
>
> I'd say this is a bug. Can you please create a jira issue? thank you.
I am curious about a proper (performant) solution for it: AFAICS, the
only way to currently fix it, is to change the offset to an offset + the
invalid counter so far. Below, in QueryResultImpl it seems to account
for 'invalid' in start, but I think 'invalid' always starts at 0, even
if the offset is not 0. This is obviously the problem. OTOH, the
performance might drop quite a bit because it means you have to start
always with the first lucene hit, to know the 'real' (combined with
authorisation) offset
org.apache.jackrabbit.core.query.lucene.QueryResultImpl
int start = resultNodes.size() + invalid + (int)offset;
int max = Math.min(result.length(), numResults);
for (int i = start; i < max && resultNodes.size() <
maxResultSize; i++) {
NodeId id =
NodeId.valueOf(result.doc(i).get(FieldNames.UUID));
// check access
try {
if (accessMgr.isGranted(id, AccessManager.READ)) {
resultNodes.add(new ScoreNode(id,
result.score(i)));
} else {
invalid++;
}
} catch (ItemNotFoundException e) {
// has been deleted meanwhile
invalid++;
}
}
-Ard
>
> regards
> marcel
>
> hsp_ wrote:
> > jackrabbit version is 1.4 (jackrabbit-core - 1.4.5).
> > I would to know if there is a workaround for the situation
> I will explain:
> > I use searches with result limit and offset but it is working some
> > wrong for my case.
> > Lets suppose the total of nodes that will return with the search:
> >
> > NAME GRANTACCESS OFFSET
> > node1 true 0
> > node2 false 1
> > node3 true 2
> > node4 true 3
> > node5 false 4
> >
> > My page must have 2 records, so first I do a count for the
> search and
> > get size of 3 records (after filtered by my security class invoked
> > automatically by jackrabbit), so I have 2 pages to show to
> the user.
> > The first page must return 2 records, of course, and the
> second must return 1 record.
> >
> > In the first search I do set:
> > QueryImpl.setLimit(2);
> > QueryImp.setOffset(0);
> >
> > So, I get the nodes 1 and 3, thats correct.
> >
> > In the second same search (for second page), I do set:
> > QueryImpl.setLimit(2);
> > QueryImp.setOffset(2);
> > This way I pretend to get two records, starting from the
> record nro 3,
> > which would be only the node4.
> > But, the result I got is node3 (again) and node4, because
> the offset
> > worked not according to the grantacess (provided by the security
> > class), but according to the sequence of the raw result.
> >
> > Is there some way to my application handle this offset to
> start in the
> > correct position (counting only the granted nodes and not all of
> > them)? Or maybe is this an issue?
> >
> > Hope this make sense for you.
> >
> > Thanks.
> > Helio.
>
>