Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Quiery builder


Published on

Adobe CQ 5.5 Query Builder

Published in: Education
  • Login to see the comments

Quiery builder

  1. 1. A Presentation by
  2. 2. Content : What Is Query Builder? Example usages Why Query Builder? Query Builder Debugger Anatomy of a query Predicate resolution & execution Standard predicates Ordering Grouping of predicates Facets Sample Queries Javadoc Links Query Builder Demo References A Presentation by
  3. 3. What is QueryBuilder QueryBuilder is a service for building Queries searching the Java Content Repository and which are easily extensible A Query represents a JCR repository query that can be created programmatically, with a list of so-called Predicates A Predicate is a single constraint for a Query. It is a pure data model object, consisting of a parameter map based on key-value string pairs. This service allows to create queries with several convenience methods In addition, it allows to store queries in the repository and load them again. A Presentation by
  4. 4. Example usages A Presentation by
  5. 5. Why Query Builder? Because QueryBuilder is...  an API to build queries for a query engine (JCR XPath underneath)  especially via URL query parameters (GET & POSTs)  compatible with HTML forms  allowing to add/remove conditions (“predicates”) individually  allowing copy/paste of queries  easily extensible  providing some goodies (e.g. facets) A Presentation by
  6. 6. Query Builder Debugger A Presentation by
  7. 7. Anatomy of a query A Presentation by
  8. 8. Predicate resolution & execution Internally, a predicate evaluator is resolved Based on the type OSGi component (using factories) Handles:  mapping to xpath (required)  filtering of results  custom ordering mechanism  facet extraction Multiple predicates of the same type(define an order) A Presentation by
  9. 9. Standard predicates path  range  supports multiple paths  daterange  but beware: can be slow  similar property  rep:similar  JCR property  tagid& tag  different operations  language type  page languages  node type  event fulltext  calendar  full text search  example for shortening A Presentation by
  10. 10. Ordering Use (special) orderby predicate  sort ascending by default, use orderby.desc=true for descending (1) Order by JCR properties  orderby=@cq:tags  orderby=@jcr:content/cq:tags (2) Reference predicate by name  orderby=1_property  predicate evaluator must provide ordering  simply a list of properties (=> used in xpath query)  or a custom Comparator (=> run after filtering) Multiple orderings  1_orderby=@cq:tags  2_orderby=@cq:lastModified  3_orderby=nodename A Presentation by
  11. 11. Grouping of predicates A Presentation by
  12. 12. Facets  Extract set of possible values found in current result  Options for a more specific query  Facet = set of buckets  Facet = tag  Buckets = product, business, marketing  Buckets can also be custom ranges  Facet = daterange  Buckets = yesterday, last week, last year... A Presentation by
  13. 13. Sample Queries A Presentation by
  14. 14. Sample Queries A Presentation by
  15. 15. Sample Queries A Presentation by
  16. 16. Sample Queries A Presentation by
  17. 17. Javadoc LinksJavadoc Basic QueryBuilder and Query Result Buckets (contained within facets) Predicate Facet Extractors (for evaluators) JSON Result Hit Writer for Querybuilder servlet (/bin/querybuilder.json) A Presentation by
  18. 18. Query Builder Demo  Create a getimages component  Include that component on content page A Presentation by
  19. 19. Query Builder Demo  getimages.jsp contains QueryBuilder API A Presentation by
  20. 20. Query Builder Demo This component is used to get images from dam:Asset/jcr:content/image/jpeg tag A Presentation by
  21. 21. References m/customizing_and_extendingcq5dam/quer y_builder.html adoc/com/day/cq/search/QueryBuilder.html der.pdf adoc/com/day/cq/search/Query.html A Presentation by