Elasticsearch Viewtool - Documentation topics on: elastic search,elasticsearch viewtool,es viewtool,velocity tools,viewtools,.

Elasticsearch Viewtool

The Elasticsearch viewtool allows a Widget to perform an Elasticsearch query (using full Elasticsearch JSON syntax) and return a list of results which you can iterate over using Velocity. Elasticsearch queries can be tested in the Elasticsearch Portlet before using them with the viewtool.

In the following example, an Elasticsearch query is supplied to the $estool.search viewtool method to search every Content title containing the word “gas” in the dotCMS content store. The query also prevents matches of any non-English versions of the content, using the “must_not” range for any languageid greater than 1.

#set($results = $estool.search('{
    "query": {
        "bool": {
            "must": {
                "term": {
                    "title": "gas"
            "must_not"": {
                "range"": {
                    "languageid"": {
                        "from"": 2,
                        "to"": 20

#foreach($con in $results)


For more examples of Elasticsearch queries, please see the Elasticsearch Examples documentation.