Download - Quiery builder
![Page 1: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/1.jpg)
A Presentation by
![Page 2: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/2.jpg)
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
![Page 3: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/3.jpg)
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
![Page 4: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/4.jpg)
Example usages
A Presentation by
![Page 5: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/5.jpg)
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
![Page 6: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/6.jpg)
Query Builder Debugger
A Presentation by
![Page 7: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/7.jpg)
Anatomy of a query
A Presentation by
![Page 8: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/8.jpg)
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
![Page 9: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/9.jpg)
Standard predicates
path supports multiple paths but beware: can be slow
property JCR property different operations
type node type
fulltext full text search
range daterange similar
rep:similar tagid & tag language
page languages event
calendar example for shortening
A Presentation by
![Page 10: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/10.jpg)
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
![Page 11: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/11.jpg)
Grouping of predicates
A Presentation by
![Page 12: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/12.jpg)
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
![Page 13: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/13.jpg)
Sample Queries
A Presentation by
![Page 14: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/14.jpg)
Sample Queries
A Presentation by
![Page 15: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/15.jpg)
Sample Queries
A Presentation by
![Page 16: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/16.jpg)
Sample Queries
A Presentation by
![Page 17: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/17.jpg)
Javadoc Links
Javadoc Description
com.day.cq.search Basic QueryBuilder and Query API
com.day.cq.search.result Result API
com.day.cq.search.facets Facets
com.day.cq.search.facets.buckets Buckets (contained within facets)
com.day.cq.search.eval Predicate Evaluators
com.day.cq.search.facets.extractors Facet Extractors (for evaluators)
com.day.cq.search.writer JSON Result Hit Writer for Querybuilder servlet (/bin/querybuilder.json)
A Presentation by
![Page 18: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/18.jpg)
Query Builder Demo
Create a getimages component Include that component on content page
A Presentation by
![Page 19: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/19.jpg)
getimages.jsp contains QueryBuilder API
Query Builder Demo
A Presentation by
![Page 20: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/20.jpg)
This component is used to get images from dam:Asset/jcr:content/image/jpeg tag
Query Builder Demo
A Presentation by
![Page 21: Quiery builder](https://reader034.vdocument.in/reader034/viewer/2022052617/5447169bafaf9f69178b489c/html5/thumbnails/21.jpg)
References
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
www.pro-vision.de/adaptto/downloads/2011_querybuilder.pdf
http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/Query.html
A Presentation by