Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

querybuilder question: return pages with a component which has a specific custom property value?

Avatar

Level 9

Hi, is there a way to return URLS for pages which have a component with a property of a specific value?

 

E.g. if there are say 1000 games, and each has an overview page, and each of these pages has a game overview component which has a game ID and game name property.

 

The client website has a list of recently played game ids, and needs to load some thumbnails which are aspects of the games overview page.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@TB3dock 

Use the following query builder query to get desired output 

path=/content/game
property=sling:resourceType
property.value=sample/components/structure/game-overview
group.1_property=gameId
group.1_property.value=0 (Optional)
group.2_property=gameName
group.2_property.value=0 (Otional)
group.p.and=true
p.limit=-1

 I am considering all the possible scenarios here as per provided description.

View solution in original post

6 Replies

Avatar

Level 4

@TB3dock Yes, please use the query builder tool "/libs/cq/search/content/querydebug.html" to get the results with the help of the below query 

 

Search for specific property : 

path=/content/my-project

type=nt:unstructured

property=gameid

property.value=gameid-value

p.limit=-1

 

Search for property exist

path=/content/my-project

property=gameid

property.operation=exists

property.value=true

p.limit=-1

 

OR with SQL2 : 

 

All nodes where a property contains some String OR Value

SELECT * FROM [nt:unstructured] AS node

WHERE ISDESCENDANTNODE(node, "/search/in/path")

AND CONTAINS([propertyName], "someString")

 

Thanks,

Sanket

Avatar

Correct answer by
Community Advisor

@TB3dock 

Use the following query builder query to get desired output 

path=/content/game
property=sling:resourceType
property.value=sample/components/structure/game-overview
group.1_property=gameId
group.1_property.value=0 (Optional)
group.2_property=gameName
group.2_property.value=0 (Otional)
group.p.and=true
p.limit=-1

 I am considering all the possible scenarios here as per provided description.

Avatar

Level 9

This is awesome, thanks. Is it possible to specify the type of the component which has the property using type:xxxx?  if so, how do I find out the value of xxxx?

Avatar

Community Advisor
@TB3dock it will return page + component path. not sure about in your case. please attach some screenshots for quick understanding

Avatar

Level 9

The response contains an array of found pages, with each having the following data:

  1. 0: {,…}
    1. excerpt: ""
    2. lastModified: "2021-03-10 12:21:29"
    3. name: "game"
    4. path: "/content/myweb/en/games/flappy-bird-game/jcr:content/root/aemnavcomponent/contentpage/game"
    5. title: "game"

 

Is there any way to get the gameId in the response? Then we could do one query for all games, vs. one query per game.

 

Thanks!

Avatar

Community Advisor
@TB3dock Yes exactly. Now create List<Resource> resourceList using searchResult.getResources()

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now