Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Querybuilder query for resources with a field with a null value?

Avatar

Level 4

I'm looking for a Querybuilder query for resources that have a field with a null value. 

 

This solution seems to indicate there's a way to do this with SQL2, but is there a way to do this with a Predicate style search? 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Preston,

According to JCR documentation NULL value defines situation when given property is not present.

In SQL2 getting nodes without specific property can be achieved like below using IS NULL:

 

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([/content/we-retail/language-masters/en/men]) and s.[jcr:content/pageTitle] IS NULL

 

The equivalent for querybuilder could be like that:

 

path=/content/we-retail/language-masters/en/men
type=cq:Page
property=jcr:content/pageTitle
property.operation=not

 

Please also check list of all supported predicates:

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/query-builder/quer... 

View solution in original post

5 Replies

Avatar

Community Advisor

@Preston Please try the query like below , it works

 

path=<PATH>
type=cq:Page
property=jcr:content/test
property.value=%%
property.operation=like

Avatar

Community Advisor

Nope.. it doesnt work. It bring the one with value too. AFAIK I feel you should do iterate for the property exists query and check if the value is empty as suggested here. 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-query-for-property-wit...

 

Avatar

Correct answer by
Community Advisor

Hi @Preston,

According to JCR documentation NULL value defines situation when given property is not present.

In SQL2 getting nodes without specific property can be achieved like below using IS NULL:

 

SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([/content/we-retail/language-masters/en/men]) and s.[jcr:content/pageTitle] IS NULL

 

The equivalent for querybuilder could be like that:

 

path=/content/we-retail/language-masters/en/men
type=cq:Page
property=jcr:content/pageTitle
property.operation=not

 

Please also check list of all supported predicates:

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/query-builder/quer... 

Avatar

Administrator

@Preston Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 4

I believe so. I also needed to check for if a field was possibly an empty string (so empty or null) and that doesn’t seem to be possible in Predicate syntax. Only SQL2. So I think I got my answer to the null check and hit the wall otherwise.