Query to find list of pages with a particular property | Community
Skip to main content
Level 2
February 5, 2021
Solved

Query to find list of pages with a particular property

  • February 5, 2021
  • 3 replies
  • 5320 views

Hi Team,

I am trying to get list of documents with below property (ingredion:productId). I able to fetch the properties but I need only the properties with type Long.

How to query that, can someone suggest.

 

 

 

Below is the query i am using to fetch the records.

But I want only the records whose property is property type is long.

I tried property.Type=Long but still all records are coming.

 

path=/content/dam/xyz
type=dam:Asset
1_property=jcr:content/metadata/ingredion:productIds

 

Thanks,

Chandra

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 Anudeep_Garnepudi

@chandrareddy 

I think you can not directly get the multivalued property using Query. Do it this way, query for STRING which will return both String and String[] and then check if the value is multiple or not.

Query: "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node, '/content/your/path') AND PROPERTY(node.[ingredion:productId], 'String') LIKE '%'"

For each result check if property is  Multivalued.

while (resultNodes.hasNext()) { ... if (resultNode.getProperty("ingredion:productId").isMultiple()) { // Logic } }

 

3 replies

Sanket_Kumbharkhane
Level 4
February 5, 2021

Hi @chandrareddy ,

you can refer to below examples: 

 

Using Xpath: 

 

path=/search/in/path
type=nt:unstructured
property=ingredion:productId
property.operation=exists
property.Type=Long
p.limit=-1

 

execute in =>  /libs/cq/search/content/querydebug.html

 

Or

 

SQL2 :

 

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND PROPERTY(node.[ingredion:productId], "Long") LIKE "%"

 

Level 2
February 5, 2021

Thanks for the reply sanket. 

This is fetching all records.property.Type=Long  is not working it seems. 

Kiran_Vedantam
Community Advisor
Community Advisor
February 5, 2021

Hi @chandrareddy,

 

You can use this SQL Query:

 

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "CONTENT-PATH")
AND CONTAINS([PROPERTY-NAME], "PROPERTY-VALUE")

 

Execute this in your CRX-DE query section. You can find similar queries here

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Level 2
February 11, 2021

https://gist.github.com/floriankraft/8b3720464318cd5cd9e2 helped me to find the required list.

 

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND PROPERTY(node.[propertyName], "DATE") LIKE "%"

 Thanks a lot.  

Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
February 5, 2021

@chandrareddy 

I think you can not directly get the multivalued property using Query. Do it this way, query for STRING which will return both String and String[] and then check if the value is multiple or not.

Query: "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node, '/content/your/path') AND PROPERTY(node.[ingredion:productId], 'String') LIKE '%'"

For each result check if property is  Multivalued.

while (resultNodes.hasNext()) { ... if (resultNode.getProperty("ingredion:productId").isMultiple()) { // Logic } }