-
Language:
English
-
Language:
English
Red Hat Training
A Red Hat training course is available for Red Hat JBoss Data Virtualization
Chapter 6. Query and Search
The JCR API defines a way to query a repository for content that meets user-defined criteria. The JCR 2.0 API actually makes it possible for implementations to support multiple query languages, and the specification requires support for two languages: JCR-SQL2 and JCR-QOM. JCR 1.0 defined two other languages (XPath and JCR-SQL), though these languages were deprecated in JCR 2.0.
6.1. Query Languages
At this time, the hierarchical database supports five query languages:
- JCR-SQL2
- JCR-SQL
- XPath
- JCR-JQOM (programmatic API)
- full-text search (a language that reuses the full-text search expression grammar used in the second parameter of the
CONTAINS(...)
function of the JCR-SQL2 language)
It is best to pick the language for each query that expresses your application's needs. The JCR-SQL2 language is expressive, and is technically a superset of JCR-SQL. But sometimes it will be easier to specify path-oriented criteria using XPath. Or sometimes you only need to do full-text search, in which case the full-text search language is more appropriate.
Note
Not all JCR implementations execute their queries in the same way. Some (including Jackrabbit) have completely different execution paths for different languages, meaning queries in some languages are faster than equivalent queries expressed in other languages.