Questions tagged [jcr-sql2]

JCR-SQL2 is a query language defined by the Java Content Repository 2.0 (JSR-283) specification. It is similar to a subset of SQL but also provides JCR-specific elements. JCR-SQL2 is an improvement over JCR-SQL, the original language defined in JCR 1.0 that was far less like SQL.

JCR-SQL2 queries are simple string statements that include common relational operators:

  • The SELECT clause identifies which JCR properties are to be returned in the tabular result set, and may include aliases
  • The FROM clause identifies the JCR node types (conceptually similar to tables or view) or joins that are to be sources of nodes
  • The optional WHERE clause lists any predicates that must be satisfied before nodes can be included in the results
  • The optional ORDER BY clause the specifies how the results are to be ordered

An example JCR-SQL2 query is this query:

SELECT file.*,content.* FROM [nt:file] AS file 
JOIN [nt:resource] AS content ON ISCHILDNODE(content,file) 
WHERE LOCALNAME(file,'*.txt') AND ISDESCENDANTNODE(file,[/a/b/c])

This query finds all nodes of type nt:file with a name that matches the *.txt pattern that exist somewhere under the /a/b/c node, and the nt:file node's child of type nt:resource node. The result set will minimally include a column for each of the properties defined on nt:file (e.g., "jcr:created" and "jcr:createdBy") and nt:resource (e.g., "jcr:mimeType", "jcr:encoding", "jcr:lastModified", "jcr:lastModifiedBy"); implementations are allowed to return additional columns.

Some JCR implementations (such as Jackrabbit) support only the required grammar, while other JCR implementations (such as ModeShape) support an extended grammar with additional functionality.

The JCR-SQL2 language is surprisingly powerful and flexible, and provide an easy way to find repository content independent of where that content exists in the repository's hierarchical structure of nodes.

Links

105 questions
0
votes
1 answer

Error: javax.jcr.query.InvalidQueryException: Encountered "["

I tried to execute following queries in cq search jsp. It is throwing Error: javax.jcr.query.InvalidQueryException: Encountered "[" http://localhost:4502/crx/explorer/ui/search.jsp SELECT * FROM cq:Component WHERE ISDESCENDANTNODE([/apps]) ORDER…
Sri
  • 1,205
  • 2
  • 21
  • 52
0
votes
1 answer

Query builder API in Cq5

Hi I am implementing a Java module to fetch the pages which has a particular component. Below is the code snippet which i use, but when running the module am getting an warning Saying that no PredicateEvaluator found for 'sling:resourceType'. Kindly…
Kamal Kannan
  • 91
  • 1
  • 11
0
votes
1 answer

SQL2: Case insensitive sort

Is it possible to do a case insensitive sort in SQL2? The following statement sorts the results like [c, b, a, C, B, A] and we desire [c, C, b, B, a, A]. SELECT * FROM [nt:unstructured] WHERE [sling:resourceType] = 'photo' ORDER BY [photoTitle]…
chr
  • 11
  • 5
0
votes
1 answer

JCR query all nodes under a parent node

I am trying to list, sort and paginate all folders and files under a parent node.This is my query selecting only folders and it gives me the expected result: SELECT childFolder.[jcr:name], childFolder.[jcr:uuid] FROM [nt:base] AS parent LEFT OUTER…
0
votes
2 answers

How iterate all Property of a node and update the value of each property and save in repository in cq5

My cq5 Content Structure is.... Content ---mywebsite ------base -----us --- en ----pageOne ----pageTwo …
codePlayer
  • 15
  • 1
  • 3
0
votes
2 answers

Adobe CQ AEM: query to fetch pages by passing component name

I am using Query builder as below to get the list of distinct pages which uses the component (component name will passed as a parameter) in property. I need to pass two parameters, cq:lastReplicationAction=Activate and sling:resourceType=component…
Saravanan
  • 1
  • 1
  • 1
  • 1
0
votes
1 answer

SQL2 JCR query issue with AEM 6

I have the following query, which produces no results, but no error. I am trying to select all pages that are not "featured press releases" and are of a certain type, e.g. "Announcements". SELECT parent.* FROM [cq:Page] AS parent INNER JOIN…
Greg Burdett
  • 191
  • 2
  • 6
0
votes
1 answer

SQL2 query statement not working in CRXDE lite search tool in CQ5

Hi I'm trying to search a node whose name is "MainReference" and contains a property "id" whose value is either equal to "FK123456" or "123456" inside a given path. When I'm doing this using the query builder in the code, then it's working fine. For…
user2142786
  • 1,484
  • 9
  • 41
  • 74
0
votes
1 answer

JCR SQL2 Filtering by path

I'm trying to filter records where the path contains 'renditions' somewhere in the path. I have in the query NOT CONTAINS(s.*, 'renditions') but it returns records with renditions in the middle of the path but not at the end. Any ideas to eliminate…
0
votes
1 answer

How to query jackrabbit jcr to get nodes ordered by number of matches (using SQL2/XPATH)?

Say I have nodes stored in Jackrabbit JCR repository where they have multiple 'tag' properties attached. I want to perform an or query, where any nodes that have tags with any of the tags in the query are returned. But I want them ordered by number…
Ravish Bhagdev
  • 955
  • 1
  • 13
  • 27
0
votes
1 answer

Identical Xpath query to a sql2 query?

I want identical XPATH query to trhis SQL2 Query. SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/abc/def]) and ([sling:resourceType] = 'geomatrixx/components/list' ) Is there any tool or link available through which i can convert…
user2142786
  • 1,484
  • 9
  • 41
  • 74
0
votes
1 answer

JCR: Get all ancestors of current node

Is it possible to select node ancestors by SQL2 query? For example I have: /content/categories/sport/football node Want to select: /content, /content/categories, /content/categories/sport nodes
Normal
  • 1,347
  • 4
  • 17
  • 34
0
votes
0 answers

Index and full-text-search with Jackrabbit, Lucene using Tika

Full text search not working. I am creating document management system using Apache Jackrabbit 2.9.0 and tika-parsers 1.3 In workspace.xml & repository.xml added tikaConfig
0
votes
1 answer

Creating a search query with wildcard in SQL2

I've got a request about a search, using wildcard. I created the following query SELECT * FROM [nt:base] AS p WHERE ISDESCENDANTNODE(p, [/home/users/ldap/2]) AND p.[sling:resourceType] = 'cq/security/components/profile' AND Contains (p.memberOf,…
Reporter
  • 3,897
  • 5
  • 33
  • 47
0
votes
1 answer

Jackrabbit query on jcr:content

I am using jackrabbit 2.6 and I have the following nodes structure [nt:file] |-- [nt:file] |-- [nt:resource] In nt:resource nodetype there is property "jcr:data" with the stream of the file that I want to save. I do not know how to…
semantic-dev
  • 1,095
  • 3
  • 14
  • 27