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

Query to find list of pages with a particular property

  • February 5, 2021
  • 3 replies
  • 5317 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

Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
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 } }

 

Kiran_Vedantam
New Participant
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.

New Participant
February 5, 2021
thanks for reply kiran. property.Type is String for all docs around 5k. only few may be 10 to 20 mistakenly created with property.Type=Long, need to identify those using qury
Sanket_Kumbharkhane
New Participant
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 "%"

 

New Participant
February 5, 2021

Thanks for the reply sanket. 

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