Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

AEM xpath query with contains for a certain cq page aem6.5

Avatar

Level 8

Hi ,

 

Could some one provide inputs as how to generate jcr:contains query using xpath , I would need case insensitive search but only limiting to certain node paths 

 

I am getting the below 

/jcr:root/content/project/us/en//Product_Reference_Guide//element(*, cq:Page)
[
((jcr:content/root/container/node1/_text/
@text = '%battery%'))
and (jcr:contains(jcr:content/root/container/node2/_text/
@text'%baTTery%'))
]
order by 
@jcr:score descending

 

I am using the below in querydebug.html

 

path=/content/project/us/en/Product_Reference_Guide

orderby=@jcr:score

orderby.sort=desc

type=cq:Page

group.1_property=jcr:content/root/container/node1/_text/@text

group.1_property.1_value=%battery%

fulltext.relPath=jcr:content/root/container/node2/_text/@text

fulltext=%baTTery%

 

 

I have used fulltext.relPath  which generated the jcr:contains but cannot use it on other path 

when I use group.1_property  it does not again generate jcr:contains

 

How to solve this. Any inputs will be helpful.

 

Regards,

Srinivas

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

are you looking for something like the below one -

 

path=/content/we-retail/language-masters/en
type=cq:Page
fulltext=experience
fulltext.relPath=jcr:content
1_property=jcr:content/cq:lastReplicationAction
1_property.value=Activate
2_property=jcr:content/clientlibsJsHead
2_property.value=dam.gui.coral.brandportal.configurations
p.limit=-1

DEBAL_DAS_0-1654577874413.png

 

View solution in original post

6 Replies

Avatar

Level 8

Hi,

 

Any inputs from any one as how to generate jcr:contains query using xpath for multiple properties and certain search text

 

Regards,

Srinivas

 

 

Avatar

Correct answer by
Community Advisor

are you looking for something like the below one -

 

path=/content/we-retail/language-masters/en
type=cq:Page
fulltext=experience
fulltext.relPath=jcr:content
1_property=jcr:content/cq:lastReplicationAction
1_property.value=Activate
2_property=jcr:content/clientlibsJsHead
2_property.value=dam.gui.coral.brandportal.configurations
p.limit=-1

DEBAL_DAS_0-1654577874413.png

 

Avatar

Level 8

Thanks for input .

 

I need to search from around 6 nodes from cq: page and it must contain jcr:contains for all the search as i would to search the same text under those nodes. 

 

Any inputs as how could this be done

 

/jcr:root/content/apps/us/en/Product_Reference_Guide//element(*, cq:Page)

    [

    (

              (jcr:contains(jcr:content/root/container/node1/_text/@text, '%Battery%'))

    or (jcr:contains(jcr:content/@jcr:title, '%Battery%'))

    or (jcr:contains(jcr:content/root/container/node2/_text/@text, '%Battery%'))

    or (jcr:contains(jcr:content/root/container/node3/_text/@text, '%Battery%'))

   )

    ]

    order by @jcr:score descending

 

Regards,

Srinivas

Avatar

Community Advisor

Addition to @DEBAL_DAS 

Use case insensitive like below using LOWER function

 

 "SELECT * FROM mix:title WHERE LOWER(jcr:title) = 'casesensitive'";

 

Avatar

Community Advisor

Are these 6 nodes available under a specific page?

If you are expecting to deal with multiple pages then node name like node2 , node3 might differ from one page to another page. 

Then we need to understand content node structure first.

Avatar

Level 8

Hi,

 

I was able to get jcr:contains with or with below .Thanks for the help

 

path=/content/apps/us/en/Product_Reference_Guide

orderby.sort=desc

orderby=@jcr:score

type=cq:Page

group.1_fulltext.relPath=jcr:content/root/container/node1/_text/@text

group.1_fulltext=%Battery%

group.2_fulltext.relPath=jcr:content/jcr:title

group.2_fulltext=%Battery%

group.3_fulltext.relPath=jcr:content/root/container/node2/note/_text/@text

group.3_fulltext=%Battery%

group.p.or=true

 

This gave the below query

/jcr:root/content/tcm/us/en/mobile-computers/handheld/tc5-series/TC57_Product_Reference_Guide//element(*, cq:Page)

[

(jcr:contains(jcr:content/root/container/node1/_text/@text, '%Battery% ')

or jcr:contains(jcr:content/@jcr:title, '%BaTTery%')

or jcr:contains(jcr:content/root/container/node2/note/_text/@text, '%Battery%')

)

]

order by @jcr:score descending