You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by David McKitterick <da...@gmail.com> on 2008/05/15 12:12:17 UTC

Executing query on sub node?

Hi,

I was just wondering if it was possible to execute a query on a paricular
subnode? 

For example my structure is JCR_Root/categoryX/languageX/data1/..

I know the category and language nodes, so I want to execute the query on
the set of data child nodes, but in my code it seems I can only execute the
query on the whole JCR_root e.g.

QueryManager qMgr = session.getWorkspace().getQueryManager();
QueryResult result = qMgr.createQuery(xpathQuery, Query.XPATH ).execute();

then I need to iterate through the results to find the relevant data nodes.

Is there a better way to implement a more fine tuned search? And if so would
this be more efficient?

Thanks,
David.
-- 
View this message in context: http://www.nabble.com/Executing-query-on-sub-node--tp17249967p17249967.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


RE: Executing query on sub node?

Posted by Ard Schrijvers <a....@onehippo.com>.
Hello,

> Thanks Ard.
> 
> I just noticed on another post that you wrote [1] in your 
> answer to question 1, that there maybe a performance hit by 
> using path info in the xpath statement..... so I am unsure 
> which would be quicker. Assuming my result set is large, then 
> do I include the path info as you suggested below or do I 
> avoid using the path info and use my own filtering loops to 
> identify the matching path nodes from the large resultant set?

Filtering via looping will AFAICS be slower. When you have to filter for
example 1.000.000 nodes, it will be much faster to do this via the
search obviously, then via looping. However, the search, and
specifically the first search while the caches are still empty might get
slow. 

It depends on the amount of hits you expect: if they will get very
large, try to either filter the set by adding extra criteria in the
[...] part of the xpath, or, make use of the //element(*,mynt:sometype)
trick. You can find some hints on this one in the archive as well,

Regards Ard 

> 
> Thanks,
> David.
> 
> [1]
> http://www.nabble.com/Explanation-and-solutions-of-some-Jackra
> bbit-queries-regarding-performance-td15028655.html
> 
> 
> 
> 
> 
> Ard Schrijvers-3 wrote:
> > 
> > Hello,
> > 
> >> Hi,
> >> 
> >> I was just wondering if it was possible to execute a query on a 
> >> paricular subnode?
> >> 
> >> For example my structure is JCR_Root/categoryX/languageX/data1/..
> >> 
> >> I know the category and language nodes, so I want to execute the 
> >> query on the set of data child nodes, but in my code it 
> seems I can 
> >> only execute the query on the whole JCR_root e.g.
> >> 
> >> QueryManager qMgr = session.getWorkspace().getQueryManager();
> >> QueryResult result = qMgr.createQuery(xpathQuery, Query.XPATH 
> >> ).execute();
> >>
> > 
> > Just embed the path info in the xpathQuery, so start the xpath with
> > /jcr:root/categoryX/languageX/data1
> > 
> > -Ard
> >  
> >> then I need to iterate through the results to find the 
> relevant data 
> >> nodes.
> >> 
> >> Is there a better way to implement a more fine tuned search? 
> >> And if so would this be more efficient?
> >> 
> >> Thanks,
> >> David.
> >> --
> >> View this message in context: 
> >> http://www.nabble.com/Executing-query-on-sub-node--tp17249967p
> >> 17249967.html
> >> Sent from the Jackrabbit - Users mailing list archive at 
> Nabble.com.
> >> 
> >> 
> > 
> > 
> 
> --
> View this message in context: 
> http://www.nabble.com/Executing-query-on-sub-node--tp17249967p
> 17253944.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> 
> 

RE: Executing query on sub node?

Posted by David McKitterick <da...@gmail.com>.
Thanks Ard.

I just noticed on another post that you wrote [1] in your answer to question
1, that there maybe a performance hit by using path info in the xpath
statement..... so I am unsure which would be quicker. Assuming my result set
is large, then do I include the path info as you suggested below or do I
avoid using the path info and use my own filtering loops to identify the
matching path nodes from the large resultant set?

Thanks,
David.

[1]
http://www.nabble.com/Explanation-and-solutions-of-some-Jackrabbit-queries-regarding-performance-td15028655.html





Ard Schrijvers-3 wrote:
> 
> Hello,
> 
>> Hi,
>> 
>> I was just wondering if it was possible to execute a query on 
>> a paricular subnode? 
>> 
>> For example my structure is JCR_Root/categoryX/languageX/data1/..
>> 
>> I know the category and language nodes, so I want to execute 
>> the query on the set of data child nodes, but in my code it 
>> seems I can only execute the query on the whole JCR_root e.g.
>> 
>> QueryManager qMgr = session.getWorkspace().getQueryManager();
>> QueryResult result = qMgr.createQuery(xpathQuery, Query.XPATH 
>> ).execute();
>>
> 
> Just embed the path info in the xpathQuery, so start the xpath with
> /jcr:root/categoryX/languageX/data1
> 
> -Ard
>  
>> then I need to iterate through the results to find the 
>> relevant data nodes.
>> 
>> Is there a better way to implement a more fine tuned search? 
>> And if so would this be more efficient?
>> 
>> Thanks,
>> David.
>> --
>> View this message in context: 
>> http://www.nabble.com/Executing-query-on-sub-node--tp17249967p
>> 17249967.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Executing-query-on-sub-node--tp17249967p17253944.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


RE: Executing query on sub node?

Posted by Ard Schrijvers <a....@onehippo.com>.
Hello,

> Hi,
> 
> I was just wondering if it was possible to execute a query on 
> a paricular subnode? 
> 
> For example my structure is JCR_Root/categoryX/languageX/data1/..
> 
> I know the category and language nodes, so I want to execute 
> the query on the set of data child nodes, but in my code it 
> seems I can only execute the query on the whole JCR_root e.g.
> 
> QueryManager qMgr = session.getWorkspace().getQueryManager();
> QueryResult result = qMgr.createQuery(xpathQuery, Query.XPATH 
> ).execute();
>

Just embed the path info in the xpathQuery, so start the xpath with
/jcr:root/categoryX/languageX/data1

-Ard
 
> then I need to iterate through the results to find the 
> relevant data nodes.
> 
> Is there a better way to implement a more fine tuned search? 
> And if so would this be more efficient?
> 
> Thanks,
> David.
> --
> View this message in context: 
> http://www.nabble.com/Executing-query-on-sub-node--tp17249967p
> 17249967.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> 
>