Expand my Community achievements bar.

Nomination window for the Adobe Community Advisor Program, Class of 2025, is now open!
SOLVED

How to use OR operator in xpath query language?

Avatar

Level 9

Hi All,

How to use OR operator for two different values of a JCR property?

Please help me with the syntax.

I want to get the results with two different values for cq:template property.

Thanks,

Kishore

1 Accepted Solution

Avatar

Correct answer by
Level 3

Refer the below queries for example

/jcr:root/content//*[@pageTitle='GeoMetrixx' or @jcr:title='Geometrixx Media']

In the above query i  am searching with two properties pagetitle and jcr:title with OR operator.Even AND operator work as well.

/jcr:root/content//*[@cq:template='/libs/cq/core/content/projects/templates/creative-project-management' or @cq:template='/libs/cq/core/content/projects/templates/default'] which searches for cq:template property with 2 different values.

 

Refer the below doc for more information.

http://www.fadfish.com/anatomy-of-xpath-queries-in-aem.

https://docs.jboss.org/jbossdna/0.7/manuals/reference/html/jcr-query-and-search.html#jcr-xpath-query....

View solution in original post

3 Replies

Avatar

Correct answer by
Level 3

Refer the below queries for example

/jcr:root/content//*[@pageTitle='GeoMetrixx' or @jcr:title='Geometrixx Media']

In the above query i  am searching with two properties pagetitle and jcr:title with OR operator.Even AND operator work as well.

/jcr:root/content//*[@cq:template='/libs/cq/core/content/projects/templates/creative-project-management' or @cq:template='/libs/cq/core/content/projects/templates/default'] which searches for cq:template property with 2 different values.

 

Refer the below doc for more information.

http://www.fadfish.com/anatomy-of-xpath-queries-in-aem.

https://docs.jboss.org/jbossdna/0.7/manuals/reference/html/jcr-query-and-search.html#jcr-xpath-query....

Avatar

Level 9

Thank you.

Avatar

Level 7

Hi Kishore@CQ,

If your problem has been solved, please mark it as solved.

Regards

Tuhin