Elasticsearch REST API documentation for the dotCMS Content Management System

dotCMS supports pulling Content from Elasticsearch using the REST API. This document explains the API endpoints and options, and provides several examples of how to perform Elasticsearch queries using the REST API.


There are two endpoints to the Elasticsearch REST API:

/api/es/searchReturns the normal Elasticsearch response provided by dotCMS.
This is the same response you would get if performing the same Elasticsearch query in dotCMS.
/api/es/rawReturns the raw SearchResponse directly from ElasticSearch.

Pretty Print Option

By default, the value returned from an Elasticsearch REST query will be displayed in an unformatted block (without additional spaces and carriage returns to make it easily human readable). To display the results in a more easily readable format, append ?pretty to the end of the URL. For example:

curl -H "Content-Type: application/json" -XPOST http://localhost:8080/api/es/search?pretty -d '{...


Basic Content Search

The following curl command searches for the word “gas” in any field using the “catchall” keyword to search within all fields.

curl -H "Content-Type: application/json" -XPOST http://localhost:8080/api/es/search -d '
        "query": {
            "bool": {
                "must": {
                    "term": {
                        "catchall": "gas"

For more information on searching within all fields, please see the Search Within all Content Fields documentation.

Lucene Query

The following command performs a query using the Lucene syntax and displays it using the pretty print option.

curl -H "Content-Type: application/json" -XPOST https://demo.dotcms.com/api/es/search?pretty -d '
    "query" : { 
        "query_string" : {
            "query" : "+contentType:webPageContent +webPageContent.title:about*"

    "size":3 ,

This enables you to use the simpler, compact Lucene syntax for the core query, while also using additional Elasticsearch terms and modifiers via the full JSON syntax (including sorting and limiting the number of results, as in this example).

Aggregations Query

The following curl command performs an aggregations query using the raw results endpoint:

curl -H "Content-Type: application/json" -XPOST http://localhost:8080/api/es/raw -d '
        "query" : { "query_string" : {"query" : "gas*"} },
        "aggs" : {
            "tags" : { "terms" : {"field" : "news.tags"} }

For more information on aggregation queries, please see the Elasticsearch Aggregations documentation.


The following curl performs a search to support a Suggestions feature (Did you mean?), using the raw results endpoint:

curl -H "Content-Type: application/json" -XPOST http://localhost:8080/api/es/raw -d '
      "suggest" : {
        "title-suggestions" : {
          "text" : "gs pric rollrcoater",
          "term" : {
            "size" : 3,
            "field" : "title"

For more information on implementing features such as suggestions, please see the Elasticsearch Examples documentation.