jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix Meschberger" <Felix.Meschber...@day.com>
Subject Re: difference between xpath searches
Date Wed, 27 Jun 2007 05:30:49 GMT
Hi Mark,

There is some misconception here :-)

1) session.getRootNode().getNode(xPath);

This is not a search/query: - assuming you mean Node.getNodes(String) [
watch the trailing s ] - the "xPath", actually pattern, argument you submit
may not be an XPath query but a simplified pattern, which only allows
listing the direct child nodes. This method is specified to return whatever
is in the node currently as seen from the session. If there are
modifications (new nodes, removed nodes), these are reflected in the
NodeIterator returned.

2) Workspace ws = session.getWorkspace();
>     QueryManager qm = ws.getQueryManager();
>     Query q = qm.createQuery(xpath, Query.XPATH);
>     NodeIterator iter = q.execute().getNodes();
>     return iter;

As Jukka already said, a query operates on the persistent state of nodes.
That is only persisted nodes and properties will be looked up and considered
for XPath query execution. The result however might include modifications.

Consider a node /a/b which is modifed but not stored. If the search would
return that node, you would get the modified node /a/b from the node
iterator and not the persisted one.

The reason for only operating on persisted items is, that updating a search
index is a potentially expensive operation, which you would want to postpone
to the moment, when you are prepared to do expensive operations - e.g. upon
a save operation.

Hope this helps


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message