Query the Content Repository - BloomReach Experience - Open Source CMS
06-12-2019

Query the Content Repository

Introduction

Goal

Test JCR queries by executing them directly in the Repository Servlet.

Supported Query Languages

Bloomreach Experience Manager's content repository supports the following query languages:

  • XPath
  • SQL
Bloomreach Experience Manager does not support JCR-SQL2 or JCR-JQOM, although the backing repository Jackrabbit does support these languages. Even though in JSR-283 (JCR specification) both XPath and SQL are deprecated in favor of JCR-SQL2 and JCR-JQOM, the Jackrabbit implementations of Xpath and SQL have been proven better in production applications and also do not have some performance issues that have been observed with JCR-SQL2 or JCR-JQOM. 

Repository Servlet

The repository provides a developer tool that can be used to experiment with querying the repository. This tool is commonly referred to as Repository Servlet and can be found at the following URL:

http://host:port/cms/repository

After you log in, you should see something similar to the following image.

To accurately test queries that are to be executed by the delivery tier, log into the Repository Servlet as the same user the Delivery Tier uses (typically liveuser for the live web site).
If you log in as admin your query results may also contain get draft and unpublished document variants and document type prototypes.

Access the Repository Servlet with Delivery Tier User

By default since version 14.0.0,  Delivery Tier Users cannot login into the Repository Servlet any more. If you need to login with a Delivery Tier user for testing purposes in the Repository Servlet you need to add two things to the specific user. Assume you want to login with the liveuser in the Repository Servlet to perform some test queries. You then need to add to /hippo:configuration/hippo:users/liveuser via the Console:

  1. A password via hipposys:password, to be used when logging in into the Repository Servlet
  2. Add to hipposys:userroles the role xm.repository-browser.user, also see Access to CMS, Console, Repository

XPath Specification

The best place to start to learn more about the syntax and capabilities of the XPath query language is actually the JCR version 1.0 specification. You can read it here, section 6.6 covers XPath.

XPath Examples

Below you find some example XPath queries.

  • Find all nodes of type hippo:document:

//element(*, hippo:document) 
  • Find all nodes that have the property myproject:title with the value 'title':

//*[@myproject:title='title']
  • Find all nodes of type hippo:document that have the text  'title':

//element(*, hippo:document)[jcr:contains(., 'title')]
  • Find all nodes of type hippo:document that have the text  'title' in the property myproject:title:

//element(*, hippo:document)[jcr:contains(@myproject:title, 'title')]
  • Find all the children of a node with spaces. Use @hippo:paths with the UUID of the folder:

//*[@hippo:paths='48697750-446e-40be-a5fc-b20a19ab3f11']
  • Find all document types, except those that are in a specific folder "excludeme":

//element(*,hipposysedit:namespacefolder)/element(*,mix:referenceable)[not(jcr:contains(.,'excludeme'))]/element(*,hipposysedit:templatetype)/hipposysedit:prototypes/element(hipposysedit:prototype,hippo:document)
  • Find all published text documents and order them by their last modification date:

//element(*, myproject:textdocument)[hippostd:state = 'published' and hippostd:stateSummary = 'live'] order by @hippostdpubwf:lastModificationDate descending
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?