Use Case: Your search has some custom requirement that can not be covered by existing predicate
Pre requisite:
Suppose you want to create a custom predicate to copare and sort case sensitive property.
Your predicate expression will look like
-----Signature -----
Pre requisite:
- http://www.pro-vision.de/content/medialib/pro-vision/production/adaptto/2011/2011_querybuilder-pdf/_jcr_content/renditions/rendition.file/2011_querybuilder.pdf
- http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html
- http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/QueryBuilder.html
- http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/PredicateEvaluator.html
Example:
Suppose you want to create a custom predicate to copare and sort case sensitive property.
Your predicate expression will look like
-----Signature -----
path=<Path under which search would be performed>
type=<node type>
customcase.property=<property name for which case sensitive search needs to be performed>
customcase.fulltext=<Search Text>
customcase.case=upper/lower/UPPER/LOWER/no_case/NO_CASE
orderby=customcase
You can test these example after deploying code HOST:PORT/libs/cq/search/content/querydebug.html
---- Example 1 (Find all node with subtitle as "MAIL" and do upper case compare) -----
path=/content/geometrixx/en
type=cq:Page
customcase.property=jcr:content/subtitle
customcase.fulltext=MAIL
customcase.case=upper
orderby=customcase
---- Example 2 (find all node and sort by subtitle property) -----
path=/content/geometrixx/en
type=cq:Page
customcase.property=jcr:content/subtitle
customcase.case=no_case
orderby=customcase
One more example http://labs.sixdimensions.com/blog/joe-gergis/2013-07-10/custom-predicateevaluators-or-how-i-learned-stop-worrying-and-love
And one more
https://github.com/Adobe-Marketing-Cloud/aem-docs-custom-predicate-evaluator/blob/master/src/main/java/com/adobe/aem/docs/search/ReplicationPredicateEvaluator.java
And one more
https://github.com/Adobe-Marketing-Cloud/aem-docs-custom-predicate-evaluator/blob/master/src/main/java/com/adobe/aem/docs/search/ReplicationPredicateEvaluator.java
Note: As you can see, Code is not optimal. It is just an example of how you can create your own predicate. Also Example assumes that you know how to import dependencies for this code. Let me know if you have any question.
Hi Yogesh,
ReplyDeleteAll of yours blogs are very useful.I have a query regarding Restful API in adobe cq. i want to know what is a scope of restful api in adobe cq where it is n use some for info on it..
thanks in advance
Hello Pankaj,
DeleteYou can get more information about REST from http://en.wikipedia.org/wiki/Representational_state_transfer. From within CQ please refer http://dev.day.com/docs/v5_1/html-resources/cq5_guide_developer/ch02s08.html
Yogesh
Thanks yogesh god bless you :)
ReplyDeleteHi , Yogesh Upadhyay
ReplyDeleteYour blog displayed on '' Educational Act '' that I followed your blog . I got more tips by this your blog . This blog given us attractive concepted . Obviously , I signatured your blog . Private property management owners must know the top elements of a very successful residence. If you are looking to spend money on property and have your newly obtained residence up for rental, it will pay to understand that property doesn't just start with purchasing a residence but in setting up the economical predicament where you can buy that residence. It is also essential to recognize that there is a lot of perform to be conducted right from the first step when a decision is created to spend money on property to actually purchasing the residence, especially for first-time traders. Having residence is a complicated and a tough company, that is why it is beneficial to make a analysis when shopping for an income residence as well as the techniques on how to avoid problems that can eliminate your financial commitment profits.
Thank you for your Excellent Blog .
Hi Yogesh, I deployed this component & tried this example1 & getting an error Caused by: java.text.ParseException: Query:
ReplyDelete/jcr:root/content/geometrixx/en//*[fn:upper-case(@jcr:content/(*)subtitle)='MAIL']; expected: )
I also have set the property under /content/geometrixx/en/company/press/jcr:content subtitle-MAIL. Any idea, BTW i am using AEM6.
Hi Yogesh! Could you please update links. Few links are directing to 404.
ReplyDelete