You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by ChadDavis <ch...@gmail.com> on 2010/02/22 20:06:27 UTC

JQOM Descendant Node Constraint Problem

Jackrabbit 2.0.0

I'm AND'ing a FullTextSearch constraint with a DescendantNode
constraint.  If I use the root node as the path to the descendent node
constraint, i.e. if I use "/", then it works.  However, if I specify
the path to one of my own application defined nodes in the repository,
the return set is empty.  Note, I have even used the path to retrieve
the node, with session.getNode(), to verify that my path was correct.
I even used that node's .getPath() to provide the value to the
constraint factory, still nothing.

Here's my code.  Can anyone spot an error?  Or explain the behavour to
me.  I kind of think it's a bug . . .

//prepare the full text search constraint
ValueFactory valueFactory = session.getValueFactory();
Value target = valueFactory.createValue(queryString);
Literal queryStringLiteral = qomFactory.literal(target);
Constraint fullTextSearchConstraint =
qomFactory.fullTextSearch("mySelector", null, queryStringLiteral );

//prepare the root folder constraint
Constraint rootFolderConstraint =
qomFactory.descendantNode("mySelector", "/group one/documents/my
folder" );

//AND the two constraints
And textQueryAndRootFolderConstraints = qomFactory.and(
fullTextSearchConstraint, rootFolderConstraint );

//build query and execute
QueryObjectModel queryObjectModel = qomFactory.createQuery(
allDocsSelector, textQueryAndRootFolderConstraints, null, null);
QueryResult results = queryObjectModel.execute();

Re: JQOM Descendant Node Constraint Problem

Posted by ChadDavis <ch...@gmail.com>.
Okay.  I think I've narrowed it down.  I've found two bugs /
behavioral issues in the DescendantNode factory creation method.

1) Requires that the absolute path ends with a slash

 In other words:

 qomFactory.descendantNode("mySelector","/documents/myFolder" );


does not work, but the following does work:

 qomFactory.descendantNode("mySelector","/documents/myFolder/" );


NOTE:  session.getNode( ) works with both path forms.  For the record,
the JCR specification doesn't show a trailing slash on absolute paths
( Sect. 3.4.4 Absolute and Relative Paths )


2) Even if I construct the path to end in a slash, if my folder name
includes spaces, this too seems to break the factory method.  So, the
following will note work:

 qomFactory.descendantNode("mySelector","/documents/My Folder/" );

Even though the following works just fine:

session.getNode("mySelector","/documents/My Folder/");