Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

AEM query to fetch pages with value is not equal to

Avatar

Level 6

Hi Team,

 

I need a query to get list of pages where one the value should not be equal.

 

For example:

 

This is my query:

 

path=content path here
type=cq:Page
1_property=jcr:content/cq:lastReplicationAction
1_property.value=Activate
2_property=jcr:content/channel
2_property.operation=unequals
2_property.value=channel:search
p.limit=-1

 

I need list of pages, whose channel value should not equal to "channel:search"

The above query is  (jcr:content/@cQ:lastReplicationAction = 'Activate' and jcr:content/@channel != 'channel:search')

 

Here the channel type is multistring 

akhilr48142671_0-1676300170905.png

 

The result of above query is still giving page results where the value is present.

 

Please let me know what is wrong, is it failing because channel is a multi String ?

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @akhilraj ,

 

You would need to use JCR-SQL2 for this use case.

 

 

select * from [cq:Page] as t WHERE ISDESCENDANTNODE(t,'/content/wknd') AND t.[jcr:content/cq:lastReplicationAction] = 'Activate' AND t.[jcr:content/channel] NOT LIKE 'channel:search'

 

 

Content with channel:search not being returned.

Screenshot (2065).png

Content without channel:search gets returned.

Screenshot (2066).png

 

Thanks,

Ram

 

View solution in original post

9 Replies

Avatar

Level 6

Hi @Anish-Sinha  @Saravanan_Dharmaraj ,

 

2_property=jcr:content/channel
2_property.operation=not
2_property.value=channel:search

This condition is checking whether channel property exists or not and ignoring the value.

Even if channel exists with a different value other than channel:search, it is not listing.

 

XPATH query:

 

/jcr:root/content/cs//element(*, cq:Page)
[
(jcr:content/@cq:lastReplicationAction = 'Activate' and not(jcr:content/@channel))
]

 

Avatar

Employee Advisor

Hi @akhilraj ,

Try adding not instead of unequal for property 2 operation and it should work:

path=content path here
type=cq:Page
1_property=jcr:content/cq:lastReplicationAction
1_property.value=Activate
2_property=jcr:content/channel
2_property.operation=not
2_property.value=channel:search
p.limit=-1

 

Avatar

Community Advisor

please try this and see

 

path=content path here
type=cq:Page
1_property=jcr:content/cq:lastReplicationAction
1_property.value=Activate
2_property=@jcr:content/channel
2_property.operation=not
2_property.value=channel:search
p.limit=-1

Avatar

Employee Advisor

Hi @akhilraj ,

 

I tried this query on my local and it works. please check - 

type=cq:PageContent
path=/content/mynewsite/language-masters/en
p.limit=-1
1_property=cq:tags
1_property.value=we-retail:activity/hiking
1_property.operation=like
p.not=true

Avatar

Community Advisor

Hey @akhilraj can you try updating 2_property.operation=unequals to 2_property.operation=ne and see if it works for you.

Avatar

Correct answer by
Level 6

Hi @akhilraj ,

 

You would need to use JCR-SQL2 for this use case.

 

 

select * from [cq:Page] as t WHERE ISDESCENDANTNODE(t,'/content/wknd') AND t.[jcr:content/cq:lastReplicationAction] = 'Activate' AND t.[jcr:content/channel] NOT LIKE 'channel:search'

 

 

Content with channel:search not being returned.

Screenshot (2065).png

Content without channel:search gets returned.

Screenshot (2066).png

 

Thanks,

Ram