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.
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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-manage... ], but it is not returning any results.
Views
Replies
Total Likes
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 ?
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
This seems to be a bug in OAK. You should probably log a day care support ticket for this.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Hi Kunal,
As we did earlier, added '*' at the end of each searchterm and it seems to be working. Validating the results.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Likes
Replies