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

askdctmAuthor
New Participant
January 15, 2016

Hi Kunal,

Could not test further due to couple of other issues. But with the test done so far, looks like it is working well.

Once again, thanks a lot for patiently responding to my queries. 

@ Ratna Kumar : Thanks a lot for your inputs.

askdctmAuthor
New Participant
January 13, 2016

Hi Kunal,

As we did earlier, added '*' at the end of each searchterm and it seems to be working. Validating the results.

askdctmAuthor
New Participant
January 13, 2016

Hi Kunal,

Thanks a lot for your reply.

Guess, the next step for me would be to tweak this query to search for occurences of similar words[i.e, Abcs, Abces etc(partial search)] as it si currently looking for only Abc.

Will try on this and keep you posted on the progress.

Kunal_Gaba_
Kunal_Gaba_Accepted solution
New Participant
January 12, 2016

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.
askdctmAuthor
New Participant
January 12, 2016

Hi Kunal,

Latest update as below :

1] If I try the below query in Query debugger [http://localhost:4502/libs/cq/search/content/querydebug.html

path=/content/x/y/z
type=cq:Page
group.1_fulltext=Abc
group.1_fulltext.relPath=jcr:content/@headingText
group.2_fulltext=Abc
group.2_fulltext.relPath=jcr:content/@headline
group.3_fulltext=Abc
group.3_fulltext.relPath=jcr:content/@blocktitle
group.4_fulltext=Abc
group.4_fulltext.relPath=jcr:content/@bodycopy
group.5_fulltext=Abc
group.5_fulltext.relPath=jcr:content/@author
group.6_fulltext=Abc
group.6_fulltext.relPath=jcr:content/@jcr:title
group.p.or=true

where couple of the properties are present at jcr:content level and some of them at component level, it is saying 

Results

Number of hits: 31

Time: 0.12 seconds

But the number of pages listed  here is 10.

2] There is also a corresponding XPath query[shown below], which is generated automatically on the Query debugger page[on the right hand side] when we run the above query.

If I take that Xpath query and run it in CRXDE-Lite, by selecting Xpath as the type, then it lists all the 31 pages.

/jcr:root/content/x/y/z//element(*, cq:Page) 
[
(jcr:contains(jcr:content/@headingText, 'Abc')
or jcr:contains(jcr:content/@headline, 'Abc')
or jcr:contains(jcr:content/@blocktitle, 'Abc')
or jcr:contains(jcr:content/@bodycopy, 'Abc')
or jcr:contains(jcr:content/@author, 'Abc')
or jcr:contains(jcr:content/@jcr:title, 'Abc')) 
]

3] This is really weird. Any idea on why this might be the case.

4] Also, if put query in #1 in code and run, it is showing up very less results[no way close to 31 results]

Any thoughts on the above will be helpful.

Kunal_Gaba_
New Participant
January 12, 2016

This seems to be a bug in OAK. You should probably log a day care support ticket for this. 

askdctmAuthor
New Participant
January 12, 2016

Hi Ratna,

Thank you for your reply.

As per, https://helpx.adobe.com/experience-manager/using/using-query-builder-api1.html, the below parameters are provided :

map.put("path", "/content");
map.put("type", "cq:Page");
map.put("group.p.or", "true"); // combine this group with OR
map.put("group.1_fulltext", fulltextSearchTerm);
map.put("group.1_fulltext.relPath", "jcr:content");
map.put("group.2_fulltext", fulltextSearchTerm);
map.put("group.2_fulltext.relPath", "jcr:content/@cq:tags");
 

 

Couple of doubts as below :

 

1] Having "jcr:content/custom" will search for "custom" property anywhere under the page[I mean at page jcr:content level or component level or anywhere in that page]?

 

2] Initially when I tried it looked like it worked for couple of scenarios, but when testing thoroughly now, doesn't seem to be giving expected results.

askdctmAuthor
New Participant
January 12, 2016

Hi Kunal,

Yes, along with Lower case function, we are using lower case search terms, something similar to the below you mentioned :

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

Kunal_Gaba_
New Participant
January 12, 2016

That should not be the case. I hope you are also using the lower case search values in the query along with the lower case function ?

askdctmAuthor
New Participant
January 12, 2016

Hi Kunal,

Sorry forgot to mention that.

Had given that a try[ by looking at the article http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__wrfi-hi_i_have_seena.html ], but it is not returning any results.