Query to find list of pages with a particular property

Avatar

Avatar

chandrareddy

Avatar

chandrareddy

chandrareddy

05-02-2021

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.

 

chandrareddy_0-1612519384506.png

 

 

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Anudeep_Garnepudi

MVP

Avatar

Anudeep_Garnepudi

MVP

Anudeep_Garnepudi
MVP

05-02-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
    }
}

 

Answers (2)

Answers (2)

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

05-02-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.

Avatar

Avatar

Sanket_Kumbharkhane

Avatar

Sanket_Kumbharkhane

Sanket_Kumbharkhane

05-02-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 "%"