Query the Content Repository

Overview

This page explains how to test JCR queries directly in the Repository Servlet and provides guidance on supported query languages, usage, and example queries.

Supported Query Languages

Bloomreach Content supports the following query languages for interacting with the content repository:

  • XPath
  • SQL

Note: Bloomreach Content does not support JCR-SQL2 or JCR-JQOM, even though the underlying repository (Jackrabbit) does. While JSR-283 (the JCR specification) deprecates XPath and SQL in favor of JCR-SQL2 and JCR-JQOM, Jackrabbit's XPath and SQL implementations are more reliable in production and do not exhibit some performance issues found in JCR-SQL2 and JCR-JQOM.

Repository Servlet

The Repository Servlet is a developer tool for running queries against the content repository. Access it at:

http://host:port/cms/repository

After logging in, you will see a screen similar to the following:

Repository Servlet XPath query screen showing root node contents

Tip: To test queries as they will run in the delivery tier, log in to the Repository Servlet as the same user the Delivery Tier uses (typically liveuser for the live website).
Logging in as admin may return draft and unpublished document variants and document type prototypes in your query results.

Granting Repository Servlet Access to Delivery Tier Users

Starting with version 14.0.0, Delivery Tier Users cannot log in to the Repository Servlet by default. To enable a Delivery Tier user (for example, liveuser) to log in for testing:

  1. In the Console, navigate to /hippo:configuration/hippo:users/liveuser.
  2. Set a password using the hipposys:password property.
  3. Add the xm.repository-browser.user role to the hipposys:userroles property. For more details, see Access to CMS, Console, Repository.

XPath Query Language Reference

For details on XPath query syntax and capabilities, refer to the JCR 1.0 specification, section 6.6: JCR 1.0 Specification – XPath.

XPath Query Examples

The following examples demonstrate common XPath queries for the content repository.

  • Retrieve all nodes of type hippo:document:
//element(*, hippo:document) 
  • Find all nodes with the property myproject:title set to 'title':
//*[@myproject:title='title']
  • Retrieve all nodes of type hippo:document containing the text 'title':
//element(*, hippo:document)[jcr:contains(., 'title')]
  • Retrieve all nodes of type hippo:document where the property myproject:title contains the text 'title':
//element(*, hippo:document)[jcr:contains(@myproject:title, 'title')]
  • Find all children of a node identified by a specific UUID using @hippo:paths:
//*[@hippo:paths='48697750-446e-40be-a5fc-b20a19ab3f11']
  • Retrieve all document types except those in a folder named "excludeme":
//element(*,hipposysedit:namespacefolder)/element(*,mix:referenceable)[not(jcr:contains(.,'excludeme'))]/element(*,hipposysedit:templatetype)/hipposysedit:prototypes/element(hipposysedit:prototype,hippo:document)
  • Retrieve all published text documents and order them by the last modification date (descending):
//element(*, myproject:textdocument)[hippostd:state = 'published' and hippostd:stateSummary = 'live'] order by @hippostdpubwf:lastModificationDate descending
Share Feedback
Page: /build/development-tools/query-the-repository
Section: Build
Category *