AEM query to fetch pages with value is not equal to | Community
Skip to main content
akhilraj
Level 5
February 13, 2023
Solved

AEM query to fetch pages with value is not equal to

  • February 13, 2023
  • 6 replies
  • 4103 views

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/@5644378:lastReplicationAction = 'Activate' and jcr:content/@channel != 'channel:search')

 

Here the channel type is multistring 

 

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 ?

 

 

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 rampai

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.

Content without channel:search gets returned.

 

Thanks,

Ram

 

6 replies

Kiran_Vedantam
Community Advisor
Community Advisor
February 13, 2023

Hi @akhilraj 

 

Example for not equals to:: https://stackoverflow.com/questions/47799479/aem-query-builder-search-where-property-does-not-exist

 

Hope it helps!

Thanks,
Kiran Vedantam

akhilraj
akhilrajAuthor
Level 5
February 13, 2023

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))
]

 

Anish-Sinha
Adobe Employee
Adobe Employee
February 13, 2023

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

 

Saravanan_Dharmaraj
Community Advisor
Community Advisor
February 13, 2023

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

Anish-Sinha
Adobe Employee
Adobe Employee
February 13, 2023

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
akhilraj
akhilrajAuthor
Level 5
February 14, 2023

Hi @anish-sinha ,

 

Thanks, but it is not working in my case:

 

 

Nitin_laad
Community Advisor
Community Advisor
February 13, 2023

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

rampai
Community Advisor
rampaiCommunity AdvisorAccepted solution
Community Advisor
February 14, 2023

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.

Content without channel:search gets returned.

 

Thanks,

Ram

 

akhilraj
akhilrajAuthor
Level 5
February 14, 2023

Hi @rampai ,

 

It is working fine with JCR-SQL2.

Thank you!