My Love for Query Builder in CQ5

I have been a strong advocate of query builder for last few weeks and would now continue to remain so. Recently, i had few different requirements all of which essentially involved searching nodes at different locations in the repository some were w.r.t dam assets ,some were custom nodes and then tags. At first, i wrote a servlet that traversed within the repository and then a colleague of mine showed me the query builder api and i instantly fell in love with this utility.

Query builder api is used for searching nodes(should always be used no exception, because it reduces your coding time drastically) and obviously you can create filters in that search which in QueryBuilder terms are called as Predicates. These predicates are evaluated with PredicateEvaluator and results are returned by query. The most problematic aspect of using querybuilder is to write right set of properties and see the results.

You can also write custom PredicateEvaluator if the ones provided OOTB do not suit your needs but this will only happen in farthest cases as most of the PredicateEvaluator are already provided. You can see the query results via querybuilder servlet registered at /bin/querybuilder and provides the response in json format an example can be like this

Read comparison between Jcr SQL-2 vs Xpath


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s