Retrieve properties present at the component level [along with jcr:content properties ]via Query Builder API | Community
Skip to main content
New Participant
January 11, 2016
Solved

Retrieve properties present at the component level [along with jcr:content properties ]via Query Builder API

  • January 11, 2016
  • 17 replies
  • 5079 views

Hi All,

We are able to retrieve properties present at the page level[directly under jcr:content of page] via Query Builder API.

However, we have a requirement wherein we need to search for specific properties [along with properties under jcr:content] present under various components[those components may be present on any page, any number of times].via Query builder api and we are unable to do the same.

Any thoughts/pointers/reference code on this will be really helpful.

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 Kunal_Gaba_

By default the query builder API return only 10 results. If you want to return all the results then you need to set the limit field in the query. 

The below is mentioned in the documentation - https://docs.adobe.com/docs/en/aem/6-1/develop/search/querybuilder-api.html

  • By default, the query builder json servlet displays 10 hits. Adding the parameter of p.limit=-1allows the servlet to show the entire query result.

17 replies

Kunal_Gaba_
New Participant
January 12, 2016

You can use the lower-case function to make it case insensitive- 

path=/content/x/y/z
type=nt:base
group.1_property=fn:lower-case(headingText)
group.1_property.value=%abc%
group.1_property.operation=like
group.2_property=fn:lower-case(blocktitle)
group.2_property.value=%abc%
group.2_property.operation=like
group.3_property=fn:lower-case(headline)
group.3_property.value=%abc%
group.3_property.operation=like
group.p.or=true

askdctmAuthor
New Participant
January 12, 2016

Hi Kunal,

Based on what you mentioned, we have come up with the below :

In the below query,

1] [headingText,blocktitle,headline] are the properties present on the components on the page.
2] We have made use of nt: base , as we are not able to find out any other approach[to search for properties at the component level]
3] However, one issue we are facing is that the property values are case sensitive, i.e, "Abc" and "abc" are giving different set of results.
   How should this be handled? 

Ant thoughts/pointers on this will be helpful.

path=/content/x/y/z
type=nt:base
group.1_property=headingText
group.1_property.value=%Abc%
group.1_property.operation=like
group.2_property=blocktitle
group.2_property.value=%Abc%
group.2_property.operation=like
group.3_property=headline
group.3_property.value=%Abc%
group.3_property.operation=like
group.p.or=true

askdctmAuthor
New Participant
January 12, 2016

Hi Kunal,

Need a minor clarification from your end as below :

1]  If we use type = nt:base instead of type = nt:page, will it again impact the performance of the query and slow down things.

2] Are there any other approaches too, that can be taken here.

Ratna_Kumar
New Participant
January 11, 2016

Hi,

You can check this article which contains for your use case: http://helpx.adobe.com/experience-manager/using/using-query-builder-api1.html

Hope this helps you!

Thanks,
Ratna Kumar.

Kunal_Gaba_
New Participant
January 11, 2016

In that case you can directly query the nt:base node like below- 

type=nt:base
1_property=sling:resourceType
1_property.value=geometrixx/components/title
path=/content/geometrixx

But in the result now you will get full node paths instead of the page paths. 

askdctmAuthor
New Participant
January 11, 2016

Hi Kunal,

In the example you provided, 1_property was provided with the value "jcr:content/par/title/sling:resourceType".

1] Suppose, if this title component was present at various places in the page, [i,e not under par but /content/geometrixx/en/company/bod/jcr:content/component ABC/component DEF/title and at various other levels in the page]. Then how should this be addressed, because I will not know the value of 1_property in the query to be run?

2] Basically, when I do not know the exact location the component is present on the page[w.r.t jcr:content]  because it can appear at anywhere on the page and there are thousands of pages to be checked, then what should be the approach taken.

Any thoughts/pointers/code reference will be helpful.

Kunal_Gaba_
New Participant
January 11, 2016

Here is an example query which queries the sling:resourceType property of a component and returns the path of the page in the result- 

type=cq:Page
1_property=jcr:content/par/title/sling:resourceType
1_property.value=geometrixx/components/title
path=/content/geometrixx

http://localhost:4502/bin/querybuilder.json?1_property=jcr%3acontent%2fpar%2ftitle%2fsling%3aresourceType&1_property.value=geometrixx%2fcomponents%2ftitle&path=%2fcontent%2fgeometrixx&type=cq%3aPage