JCR SQL2 Search for Multivalued Properties

I want to search the content repository using one or more values โ€‹โ€‹as an input parameter for a multivalued property Something like: find all nodes with the main type nt: unstructured whose multiprop property (multivalued property) contains both one "and" two ".

How is queryString passed to queryManager.createQuery, how?

Thanks.

+7
source share
1 answer

You can view criteria for multi-valued properties in the same way as other criteria. For example, the following query will find all nodes that have the value "white dog" in the "someProp" property:

SELECT * FROM [nt:unstructured] WHERE someProp = 'white dog' 

If the "someProp" property has several values, then a node with at least one value that meets the criteria will be included in the results.

To find nodes that have several values โ€‹โ€‹of a multi-valued property, simply And together several criteria. For example, the following query returns all nodes that have both specified values:

 SELECT * FROM [nt:unstructured] WHERE someProp = 'white dog' AND someProp = 'black dog' 

Any of the operators will work, including "LIKE":

 SELECT * FROM [nt:unstructured] WHERE someProp LIKE '%white%' AND someProp LIKE '%black%' 

Of course, other combinations are possible.

+13
source

All Articles