You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Brian Moseley <bc...@osafoundation.org> on 2005/08/18 05:40:54 UTC

query problem

is there anything wrong with the formulation of this xpath query statement?

/bcm/cal//element(*, caldav:resource)[@caldav:uid = 
'59BC120D-E909-4A56-A70D-8E97914E51A3']

i'm trying to find all nodes of type "caldav:resource" underneath (but 
not including) /bcm/cal where the "caldav:uid" property is the value 
given in the query.

when i execute the query, i get the below exception. looks like i'm not 
being successful in specifying a descendents-only query, but i can't 
imagine that's what's causing the exception...

thanks!

java.lang.UnsupportedOperationException
         at 
org.apache.jackrabbit.core.query.lucene.CachingMultiReader$MultiTermDocs.skipTo(CachingMultiReader.java:281) 

         at org.apache.lucene.search.TermScorer.skipTo(TermScorer.java:88)
         at 
org.apache.lucene.search.ConjunctionScorer.doNext(ConjunctionScorer.java:53)
         at 
org.apache.lucene.search.ConjunctionScorer.next(ConjunctionScorer.java:48)
         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
         at 
org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.calculateChildren(ChildAxisQuery.java:291)
         at 
org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.next(ChildAxisQuery.java:251)
         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
         at 
org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.calculateSubHits(DescendantSelfAxisQuery.java:302)
         at 
org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.next(DescendantSelfAxisQuery.java:237)
         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
         at 
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:92)
         at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
         at org.apache.lucene.search.Hits.<init>(Hits.java:43)
         at org.apache.lucene.search.Searcher.search(Searcher.java:33)
         at org.apache.lucene.search.Searcher.search(Searcher.java:27)
         at 
org.apache.jackrabbit.core.query.lucene.SearchIndex.executeQuery(SearchIndex.java:287)
         at 
org.apache.jackrabbit.core.query.lucene.QueryImpl.execute(QueryImpl.java:179)
         at 
org.apache.jackrabbit.core.query.QueryImpl.execute(QueryImpl.java:132)


Re: query problem

Posted by Brian Moseley <bc...@osafoundation.org>.
Marcel Reutegger wrote:

> thanks for the threaddump, it was very helpful.
> 
> turned out again to be a bug, argh...
> 
> See: http://issues.apache.org/jira/browse/JCR-192

ah! well, i was hoping it was something i was doing wrong that could be 
easily corrected, but i'm happy to have helped flush out a bug. thanks 
for looking into it.

Re: query problem

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Brian,

thanks for the threaddump, it was very helpful.

turned out again to be a bug, argh...

See: http://issues.apache.org/jira/browse/JCR-192

regards
  marcel

Brian Moseley wrote:
> Marcel Reutegger wrote:
> 
>> this is clearly a bug. however, your query will never return any results.
>>
>> If you want to specify an absolute XPath it must always begin with 
>> /jcr:root otherwise you won't get any results. You may also write a 
>> relative XPath, which would be something like:
>>
>> bcm/cal//element(*, caldav:resource)[@caldav:uid = 
>> '59BC120D-E909-4A56-A70D-8E97914E51A3']
>>
>> and of course using:
>>
>> //whatever
>>
>> will also work because it includes /jcr:root
>>
>> See spec section 6.6.4.3
> 
> 
> thanks for the explanation. i read the section last night before writing 
> my query code, but not being too familiar with xpath, i admit it did not 
> make a lot of sense to me :)
> 
> i added /jcr:root to the beginning of the statement, which results in:
> 
> /jcr:root/bcm/cal//element(*, caldav:resource)[@caldav:uid = 
> 'FE532DE3-5036-4C55-BA19-93FA06341B76']
> 
> 1) when i run this query against an empty subtree (/bcm/cal exists but 
> has no children), the query returns successfully with no results.
> 
> 2) when i add /bcm/cal/event1.ics with caldav:uid equal to the above 
> value and then execute the query, i get the indefinite hang. the thread 
> dump is here:
> 
> <http://builds.osafoundation.org/~bcm/threaddump.txt>
> 
> that is what happens within my tomcat-based dav server, where queries 
> are formulated against subtrees like /bcm/cal.
> 
> in contrast, my simple junit test makes queries directly against the 
> root node, like so:
> 
> /jcr:root//element(*, caldav:resource)[@caldav:uid = '2']
> 
> the unit test also performs steps 1 and 2 above and is successful both 
> times (no results for the first query, one result for the second). maybe 
> that gives you another clue.
> 
> thanks for your help!
> 
> 

Re: query problem

Posted by Brian Moseley <bc...@osafoundation.org>.
Marcel Reutegger wrote:

> this is clearly a bug. however, your query will never return any results.
> 
> If you want to specify an absolute XPath it must always begin with 
> /jcr:root otherwise you won't get any results. You may also write a 
> relative XPath, which would be something like:
> 
> bcm/cal//element(*, caldav:resource)[@caldav:uid = 
> '59BC120D-E909-4A56-A70D-8E97914E51A3']
> 
> and of course using:
> 
> //whatever
> 
> will also work because it includes /jcr:root
> 
> See spec section 6.6.4.3

thanks for the explanation. i read the section last night before writing 
my query code, but not being too familiar with xpath, i admit it did not 
make a lot of sense to me :)

i added /jcr:root to the beginning of the statement, which results in:

/jcr:root/bcm/cal//element(*, caldav:resource)[@caldav:uid = 
'FE532DE3-5036-4C55-BA19-93FA06341B76']

1) when i run this query against an empty subtree (/bcm/cal exists but 
has no children), the query returns successfully with no results.

2) when i add /bcm/cal/event1.ics with caldav:uid equal to the above 
value and then execute the query, i get the indefinite hang. the thread 
dump is here:

<http://builds.osafoundation.org/~bcm/threaddump.txt>

that is what happens within my tomcat-based dav server, where queries 
are formulated against subtrees like /bcm/cal.

in contrast, my simple junit test makes queries directly against the 
root node, like so:

/jcr:root//element(*, caldav:resource)[@caldav:uid = '2']

the unit test also performs steps 1 and 2 above and is successful both 
times (no results for the first query, one result for the second). maybe 
that gives you another clue.

thanks for your help!

Re: query problem

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Brian,

this is clearly a bug. however, your query will never return any results.

If you want to specify an absolute XPath it must always begin with 
/jcr:root otherwise you won't get any results. You may also write a 
relative XPath, which would be something like:

bcm/cal//element(*, caldav:resource)[@caldav:uid = 
'59BC120D-E909-4A56-A70D-8E97914E51A3']

and of course using:

//whatever

will also work because it includes /jcr:root

See spec section 6.6.4.3

Running a similar query with test data on my workspace returned the 
expected results when using an absolute path beginning with /jcr:root or 
when using a relative path.

I have not been able to reproduce a indefinite hang. even with the 
'wrong' absolute query.

Could you please try to create a threaddump while jackrabbit seems to 
hang and post it to this list? thanks

I'll create a jira issue in the meantime and fix the 
UnsupportedOperationException asap.

regards
  marcel

Brian Moseley wrote:
> 
> well, i updated to the latest code, including the recent search changes, 
> and things are even worse: the query seems to hang indefinitely, never 
> returning.
> 
> for what's it worth, this query works as expected:
> 
> //element(*, caldav:resource)[@caldav:uid = '1']
> 
> Brian Moseley wrote:
> 
>>
>> is there anything wrong with the formulation of this xpath query 
>> statement?
>>
>> /bcm/cal//element(*, caldav:resource)[@caldav:uid = 
>> '59BC120D-E909-4A56-A70D-8E97914E51A3']
>>
>> i'm trying to find all nodes of type "caldav:resource" underneath (but 
>> not including) /bcm/cal where the "caldav:uid" property is the value 
>> given in the query.
>>
>> when i execute the query, i get the below exception. looks like i'm 
>> not being successful in specifying a descendents-only query, but i 
>> can't imagine that's what's causing the exception...
>>
>> thanks!
>>
>> java.lang.UnsupportedOperationException
>>         at 
>> org.apache.jackrabbit.core.query.lucene.CachingMultiReader$MultiTermDocs.skipTo(CachingMultiReader.java:281) 
>>
>>         at org.apache.lucene.search.TermScorer.skipTo(TermScorer.java:88)
>>         at 
>> org.apache.lucene.search.ConjunctionScorer.doNext(ConjunctionScorer.java:53) 
>>
>>         at 
>> org.apache.lucene.search.ConjunctionScorer.next(ConjunctionScorer.java:48) 
>>
>>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>>         at 
>> org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.calculateChildren(ChildAxisQuery.java:291) 
>>
>>         at 
>> org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.next(ChildAxisQuery.java:251) 
>>
>>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>>         at 
>> org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.calculateSubHits(DescendantSelfAxisQuery.java:302) 
>>
>>         at 
>> org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.next(DescendantSelfAxisQuery.java:237) 
>>
>>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>>         at 
>> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:92)
>>         at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
>>         at org.apache.lucene.search.Hits.<init>(Hits.java:43)
>>         at org.apache.lucene.search.Searcher.search(Searcher.java:33)
>>         at org.apache.lucene.search.Searcher.search(Searcher.java:27)
>>         at 
>> org.apache.jackrabbit.core.query.lucene.SearchIndex.executeQuery(SearchIndex.java:287) 
>>
>>         at 
>> org.apache.jackrabbit.core.query.lucene.QueryImpl.execute(QueryImpl.java:179) 
>>
>>         at 
>> org.apache.jackrabbit.core.query.QueryImpl.execute(QueryImpl.java:132)
>>
>>
> 
> 

Re: query problem

Posted by Brian Moseley <bc...@osafoundation.org>.
well, i updated to the latest code, including the recent search changes, 
and things are even worse: the query seems to hang indefinitely, never 
returning.

for what's it worth, this query works as expected:

//element(*, caldav:resource)[@caldav:uid = '1']

Brian Moseley wrote:
> 
> is there anything wrong with the formulation of this xpath query statement?
> 
> /bcm/cal//element(*, caldav:resource)[@caldav:uid = 
> '59BC120D-E909-4A56-A70D-8E97914E51A3']
> 
> i'm trying to find all nodes of type "caldav:resource" underneath (but 
> not including) /bcm/cal where the "caldav:uid" property is the value 
> given in the query.
> 
> when i execute the query, i get the below exception. looks like i'm not 
> being successful in specifying a descendents-only query, but i can't 
> imagine that's what's causing the exception...
> 
> thanks!
> 
> java.lang.UnsupportedOperationException
>         at 
> org.apache.jackrabbit.core.query.lucene.CachingMultiReader$MultiTermDocs.skipTo(CachingMultiReader.java:281) 
> 
>         at org.apache.lucene.search.TermScorer.skipTo(TermScorer.java:88)
>         at 
> org.apache.lucene.search.ConjunctionScorer.doNext(ConjunctionScorer.java:53) 
> 
>         at 
> org.apache.lucene.search.ConjunctionScorer.next(ConjunctionScorer.java:48)
>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>         at 
> org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.calculateChildren(ChildAxisQuery.java:291) 
> 
>         at 
> org.apache.jackrabbit.core.query.lucene.ChildAxisQuery$ChildAxisScorer.next(ChildAxisQuery.java:251) 
> 
>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>         at 
> org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.calculateSubHits(DescendantSelfAxisQuery.java:302) 
> 
>         at 
> org.apache.jackrabbit.core.query.lucene.DescendantSelfAxisQuery$DescendantSelfAxisScorer.next(DescendantSelfAxisQuery.java:237) 
> 
>         at org.apache.lucene.search.Scorer.score(Scorer.java:37)
>         at 
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:92)
>         at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
>         at org.apache.lucene.search.Hits.<init>(Hits.java:43)
>         at org.apache.lucene.search.Searcher.search(Searcher.java:33)
>         at org.apache.lucene.search.Searcher.search(Searcher.java:27)
>         at 
> org.apache.jackrabbit.core.query.lucene.SearchIndex.executeQuery(SearchIndex.java:287) 
> 
>         at 
> org.apache.jackrabbit.core.query.lucene.QueryImpl.execute(QueryImpl.java:179) 
> 
>         at 
> org.apache.jackrabbit.core.query.QueryImpl.execute(QueryImpl.java:132)
> 
>