[
http://issues.apache.org/jira/browse/JCR-591?page=comments#action_12442559 ]
Szymon Kuzniak commented on JCR-591:
------------------------------------
I was working a bit on this issue, and found out that Lucene is used to search
for nodes, and position of node is not indexed. So I decided to fix this issue
by adding Node.getIndex to Lucene document, as a field named "position", and
add to Lucene query new TermQuery. After this operation position() started to
work, but after deleting some node it returned malformed results.
For example:
Node n1 = testRootNode.addNode("node1");
Node n2 = testRootNode.addNode("node2");
Node n3 = testRootNode.addNode("node1");
Node n4 = testRootNode.addNode("node1");
Node n5 = testRootNode.addNode("node1");
Node n6 = testRootNode.addNode("node1");
Node n7 = testRootNode.addNode("node1");
...
Query q = qm.createQuery("//node1[position()=3]", Query.XPATH);
...
assertEquals(n4, iter.nextNode()); <- passed
...
n3.remove();
testRootNode.save();
...
q = qm.createQuery("//node1[position()=3]", Query.XPATH);
...
assertEquals(n4 iter.nextNode()); <- passed
assertEquals(n5, iter.nextNode()); <-did not pass
The reason I quess, is that adjacent nodes with the same name as deleted node
are not reindexed after this operation.
So, my question is: is the approach with indexing position of node ok to you?
Should I try to reindex the adjacent nodes after delete of node?
regards Simon
> XPath position function does not work
> -------------------------------------
>
> Key: JCR-591
> URL: http://issues.apache.org/jira/browse/JCR-591
> Project: Jackrabbit
> Issue Type: Bug
> Components: query
> Affects Versions: 1.0.1
> Reporter: Przemo Pakulski
> Priority: Minor
>
> Expression with position function are supported in XPath but does not work.
> All rows are returned when equality operator is used.
> public void testXPathPosition() throws Exception {
> Node foo = testRootNode.addNode("name");
> Node bar = testRootNode.addNode("name");
> testRootNode.save();
> String xpath = "//name[position()=2]";
> Query q =
> superuser.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH);
> QueryResult result = q.execute();
> checkResult(result, 1);
> checkResult(result, new Node[]{bar});
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira