How to use OR operator in xpath query language? | Community
Skip to main content
GK-007
Level 9
April 27, 2016
Solved

How to use OR operator in xpath query language?

  • April 27, 2016
  • 3 replies
  • 2479 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by mkumar

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-language.

3 replies

mkumar
mkumarAccepted solution
Level 3
April 27, 2016

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-language.

GK-007
GK-007Author
Level 9
April 27, 2016

Thank you.

Tuhin_Ghosh
Level 8
April 27, 2016

Hi Kishore@CQ,

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

Regards

Tuhin