Apache Sling JCR Capabilities

Clone this repo:
  1. 53e40fa SLING-10676 - remove SECURITY.md which is not needed by Bertrand Delacretaz · 9 weeks ago master
  2. c731f7f SLING-10676 - add or update SECURITY.md by Bertrand Delacretaz · 9 weeks ago
  3. 9059a97 SLING-10676 - add or update SECURITY.md by Bertrand Delacretaz · 9 weeks ago
  4. 190a587 Adding sonarqube badges as per SLING-9682 by Dan Klco · 1 year, 1 month ago
  5. c249208 Updating badges for org-apache-sling-capabilities-jcr by Radu Cotescu · 1 year, 1 month ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central License

Sling Capabilities - JCR sources

This module is part of the Apache Sling project.

It provides information about the JCR repository to the Sling Capabilities module.

It is implemented separately to avoid making the core module dependent on JCR APIs.


For now, this module‘s SearchSource provides just one capability that indicates whether the Oak similarity search feature is available. Here’s typical JSON output of the CapabilitiesServlet when this source is active:

  "org.apache.sling.capabilities": {
    "data": {
      "org.apache.sling.jcr.search": {
        "similarity.search.active": "false"

To compute this value, the SearchSource needs to make a JCR query to find out whether similarity search is available - that is the case if there is at least one Oak index configuration which has @useInSimilarity = true.

That query is configurable in the SearchSource component, with a default value that should work for common cases.

The cache lifetime of that value in the SearchSource component is also configurable, with a default of 60 seconds. The component caches the query result for that amount of time to avoid making too many queries.

To execute this query, the SearchSource uses a Service User that needs read access under /oak:index.

The following feature model excerpt can be used to set that up. It also creates a /var/capabilities/public path that every user can read. Resources with the sling/capabilities resource type can be created under that path to provide access to the capabilities. See the Capabilities module documentation for more information.

"configurations": {
    "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~cq-capabilities-jcr": {
      "user.mapping": [
    "org.apache.sling.capabilities.internal.CapabilitiesServlet": {
      "resourcePathPatterns" : "/var/capabilities/.*"
  "repoinit:TEXT|true": [
    "create service user capabilities-search",
    "set ACL for capabilities-search",
    "allow jcr:read on /oak:index",
    "create path /var/capabilities/public(nt:unstructured)",
    "set ACL on /var/capabilities/public",
    "allow jcr:read for everyone",