Querybuilder query for resources with a field with a null value? | Community
Skip to main content
October 24, 2023
Solved

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

  • October 24, 2023
  • 3 replies
  • 2548 views

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? 

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 lukasz-m

Hi @preston-3,

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/querybuilder-predicate-reference.html?lang=en#property 

3 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
October 24, 2023

@preston-3 Please try the query like below , it works

 

path=<PATH> type=cq:Page property=jcr:content/test property.value=%% property.operation=like
Saravanan_Dharmaraj
Community Advisor
Community Advisor
October 24, 2023

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-with-no-value/m-p/294166

 

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
October 24, 2023

Hi @preston-3,

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/querybuilder-predicate-reference.html?lang=en#property 

kautuk_sahni
Community Manager
Community Manager
October 26, 2023

@preston-3 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
Preston-3Author
October 27, 2023

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.