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
22
votes
2 answers

Apache Jackrabbit JCA 2.7.5 .docx and .xlsx indexing

I'm ussing the Appache Jackrabbit JCA 2.7.5, the problem is that files .docx and .xlsx is not indexed. My steps : Deploy the Jackrabbit JCA as resource adapter on glassfish create a Connector Connection Pool for the resource adapter indicating the…
Aroniaina
  • 1,252
  • 13
  • 31
9
votes
1 answer

JCR SQL2 Multivalue properties search

I want to do a search in the content repository using one or more of the values as an input parameter for a multivalue property Something like: find all nodes with the primary type 'nt:unstructured' whose property 'multiprop' (multivalue property)…
silverb77
  • 279
  • 5
  • 16
8
votes
2 answers

How can I get the property of an older version of a node in jackrabbit?

I have created the node and created 3 versions. String path = "/my111"; MyClass m1 = new MyClass(); m1.setPath(path); m1.setName("Myname"); m1.setLanguage("English"); ocm.create(m1); ocm.save(); for (int i = 0; i < 4; i++) { …
vikiiii
  • 9,246
  • 9
  • 49
  • 68
7
votes
1 answer

How to use order by with multiple isdescendantnode

I am attempting to grab multiple nodes of the same type from different areas in the jcr and order them by a date. SELECT * FROM [social:asiResource] WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND [isFeatured_b] = true AND NOT…
apothic
  • 345
  • 1
  • 9
5
votes
2 answers

Why does CONTAINS find inequal text strings in JCR-SQL2?

Working with a JCR-SQL2 query I noticed that the CONTAINS operator finds nodes which do not have exactly the same string that was in the condition. Example The following query: SELECT * FROM [nt:base] AS s WHERE CONTAINS(s.*,…
pkalinow
  • 1,619
  • 1
  • 17
  • 43
5
votes
2 answers

JCR SQL2 - result query order as in JCR browser

I use an application where we can manipulate JCR nodes, typically you would rename, remove, delete, or else move them. Using the JCR API, I can access the nodes in my repository and return a set of nodes in the same order as they are in the JCR. I…
Adriano
  • 19,463
  • 19
  • 103
  • 140
5
votes
3 answers

How to run query on Apache Jackrabbit, explain with example

I am using Apache Jackrabbit as a database. In my case, root node has numbers of child nodes(only at depth 1). All child node has unique name, i.e., some Integer. Each child Node have some properties that I have used further. My task I have to take…
devsda
  • 4,112
  • 9
  • 50
  • 87
4
votes
3 answers

JCR-SQL - contains function doesn't escape special characters?

I have the following query string: SELECT jcr:title, jcr:created, jcr:description FROM cq:PageContent WHERE jcr:path LIKE '/content/.../%' AND CONTAINS (., '*') ORDER BY date ASC The problem is that the query is returning all nodes from the given…
4
votes
2 answers

JCR query by path

i am trying to query a subtree for a given node type by a this query: SELECT * FROM [my:Type] AS my WHERE PATH(my) LIKE '/content/subtree/%' somehow it does not give any results - using ISDESCENDANTNODE works - but query performance is terrible as…
light_303
  • 2,101
  • 2
  • 18
  • 35
3
votes
0 answers

ranked full text search results using Lucene with modeshape

I'm trying to get full-text search working with modeshape. I'm particularly interested in ranked results based on lucene index. Here is my repository configuration "indexProviders": { "lucene": { "classname": "lucene", …
Tejas
  • 6,508
  • 1
  • 21
  • 25
3
votes
2 answers

How to escape dynamically generated String values in a JCR SQL2 query?

Let's pretend I have a JCR 2 query string that is made like this: String sql2Query = "SELECT * FROM [cq:PageContent] " + "WHERE [aProperty] <> \" + aValue + "\""; Are there helper methods using which I can escape aValue? By the…
Behrang
  • 46,888
  • 25
  • 118
  • 160
3
votes
2 answers

How to apply aggregate functions(like MIN, MAX, COUNT) in JCR-SQL2?

I have some records stored as Nodes in JCR and the name of the node is the primary key. eg 1,2,3. But the problem starts here, the records are as follows 1,2,6,53,54 Where the numbers above are nodes under EMP unstructured node. If I do int…
Oliver
  • 6,152
  • 2
  • 42
  • 75
3
votes
2 answers

SQL2 - Get child node properties

This seems like a rather simple query but I've been banging my head for hours on this. I've got a node structure similar to below: food-group jcr:content nuts -> type=almonds meat -> beef=true fruit ->…
Delmon Young
  • 2,013
  • 5
  • 39
  • 51
2
votes
1 answer

Query All Pages Based on Compoent's Resource Type

I have this JCR-SQL2 query to get all pages that have a specific component: SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component ON ISCHILDNODE(component,page) WHERE…
superninja
  • 3,114
  • 7
  • 30
  • 63
2
votes
2 answers

jcr sql-2 get node name

i am working on aem 6.3 and would like to get page name SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE("/content/Product/Silhouettes/Accessories/Bands/Headband") If I need to retrieve name of the nodes using sql-2 , how do I achieve it?
Sri
  • 1,205
  • 2
  • 21
  • 52
1
2 3 4 5 6 7