I am having difficulties querying a jcr node in jackrabbit, containing certain property.
I've added a custom node to add mixin properties to it.
<custom = 'http://example.com/mydomain'>
[custom:extensible] mixin
- * (undefined) multiple
- * (undefined)
Then I add a nt:file nodes in the following way and to those nt:file I add my custom:extensible
documents = session.getRootNode().getNode(MainJCRConstants.MAIN_NODE);
documentNode = documents.addNode(fileName, NodeType.NT_FILE);
Node resNode = documentNode.addNode(JcrConstants.JCR_CONTENT, NodeType.NT_RESOURCE);
Binary binary = session.getValueFactory().createBinary(ins);
resNode.setProperty(JcrConstants.JCR_DATA, binary);
resNode.addMixin("custom:extensible");
resNode.setProperty("sourceSystem", "internal");
And now I want to query all [nt:file] nodes, containing property "sourceSystem" which value is equal to "internal".
After looking at the documentation I fugred I have to use something similar to:
SELECT parent.* FROM [nt:file] AS parent
INNER JOIN [custom:extensible] AS child ON ISCHILDNODE(child,parent)
WHERE CONTAINS(parent.*, 'internal') OR CONTAINS(child.*,'internal')
But this throws an exception http://pastebin.com/ZdxZPf2C
Also every other query I've tried either throws an exception or returns an empty result set.
Solution:
SELECT * FROM [nt:resource] as res INNER JOIN [custom:extensible] AS ext ON ISSAMENODE(res,ext) WHERE CONTAINS(res.sourceSystem,'internal') OR CONTAINS(ext.sourceSystem,'internal')