You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Gadbury <ga...@googlemail.com> on 2010/01/21 18:38:10 UTC

Executing Search Query - NodeIterator Order

Hi all,

I have a categories tree as follows:

http://n4.nabble.com/file/n1049969/categories%2Btree.png 

In my categories dao, I execute the following code:

	QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
	Query query = queryManager.createQuery("//element(*, atl:category)",
Query.XPATH);
	QueryResult queryResult = query.execute();
	NodeIterator nodeIterator = queryResult.getNodes();

nodeIterator does contain all categories in the tree, but they appear to be
in the same 'random' order when I loop through the iterator (see text in red
for order and name attribute).  The order does not appear to follow date
created, alphabetical, or hierachical order.  Ideally, the order of nodes
would heirachical (as in the image above, from top to bottom).

I tried setting the respectDocumentOrder param of the SearchIndex in the
reposiotry.xml (configuration) file but it made no difference to the order
returned.

Any ideas?  Thanks for reading.

Kind regards,

James

-- 
View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1049969.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Executing Search Query - NodeIterator Order

Posted by Gadbury <ga...@googlemail.com>.
After a quick test (I'm using Jackrabbit 1.6.0), I can confirm it is in
hierachical order and not the order nodes were created (just in case anyone
wants to know / stumbles on this thread).

Thanks once again.  Over and out :)
-- 
View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1100044.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Executing Search Query - NodeIterator Order

Posted by Ard Schrijvers <a....@onehippo.com>.
On Fri, Jan 22, 2010 at 2:30 PM, Gadbury <ga...@googlemail.com> wrote:
>
> p.s. I understand that if a query uses 'order by', respectDocumentOrder is
> ignored.  In the case of this query (to retrieve all categories in
> hierachical order) it requires document order but the number of catgeory

I am not totally sure anymore if document order is actually the
hierarchical order or the order in which the nodes where created

> nodes are quite small so I hope this means I will not see performance issues
> (other queries could be dealing with thousands of nodes but use the order by
> clause).

For small numbers it won't matter indeed

Regards Ard

> --
> View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1100022.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>

Re: Executing Search Query - NodeIterator Order

Posted by Gadbury <ga...@googlemail.com>.
Brilliant!  Thanks.

p.s. I understand that if a query uses 'order by', respectDocumentOrder is
ignored.  In the case of this query (to retrieve all categories in
hierachical order) it requires document order but the number of catgeory
nodes are quite small so I hope this means I will not see performance issues
(other queries could be dealing with thousands of nodes but use the order by
clause).
-- 
View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1100022.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Executing Search Query - NodeIterator Order

Posted by Ard Schrijvers <a....@onehippo.com>.
On Fri, Jan 22, 2010 at 2:22 PM, Gadbury <ga...@googlemail.com> wrote:
>
> Hi Ard,
>
> Thanks for the reply.  I ended up rebuilding the repository (removing
> repository and workspace folders).  It seems that the changes I made to the
> SearchIndex element of my repository.xml file (adding in the
> respectDocumentOrder = "true") wouldn't take effect until I recreated the
> repository.  Seems a bit of a pain having to rebuild it all to make a change
> to the repository.xml.

if you do not want to rebuild, you change it in the repository.xml
(for future workspaces) but also in the workspace.xml. The
repository.xml is used as a template for the workspace, hence after
creation of the workspace only modifying the repository.xml won't have
the desired effect

Regards Ard

>
> Thanks and kind regards,
>
> James
> --
> View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1100015.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>

Re: Executing Search Query - NodeIterator Order

Posted by Gadbury <ga...@googlemail.com>.
Hi Ard,

Thanks for the reply.  I ended up rebuilding the repository (removing
repository and workspace folders).  It seems that the changes I made to the
SearchIndex element of my repository.xml file (adding in the
respectDocumentOrder = "true") wouldn't take effect until I recreated the
repository.  Seems a bit of a pain having to rebuild it all to make a change
to the repository.xml.

Thanks and kind regards,

James
-- 
View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1100015.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Executing Search Query - NodeIterator Order

Posted by Ard Schrijvers <a....@onehippo.com>.
On Thu, Jan 21, 2010 at 6:38 PM, Gadbury <ga...@googlemail.com> wrote:
>
> Hi all,
>
> I have a categories tree as follows:
>
> http://n4.nabble.com/file/n1049969/categories%2Btree.png
>
> In my categories dao, I execute the following code:
>
>        QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
>        Query query = queryManager.createQuery("//element(*, atl:category)",
> Query.XPATH);
>        QueryResult queryResult = query.execute();
>        NodeIterator nodeIterator = queryResult.getNodes();
>
> nodeIterator does contain all categories in the tree, but they appear to be
> in the same 'random' order when I loop through the iterator (see text in red
> for order and name attribute).  The order does not appear to follow date
> created, alphabetical, or hierachical order.  Ideally, the order of nodes
> would heirachical (as in the image above, from top to bottom).
>
> I tried setting the respectDocumentOrder param of the SearchIndex in the
> reposiotry.xml (configuration) file but it made no difference to the order
> returned.

Did you set it in the workspace.xml, or did you start with an entirely
clean repository after changing the repository.xml. Namely, the
repository.xml only functions as a template.

Also note, that respectDocumentOrder has a bad influence on the
performance of queries

Ard

>
> Any ideas?  Thanks for reading.
>
> Kind regards,
>
> James
>
> --
> View this message in context: http://n4.nabble.com/Executing-Search-Query-NodeIterator-Order-tp1049969p1049969.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>