Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

MaineC/elasticsearch-query-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Query templating plugin for ElasticSearch

Installation

For latest master installation clone the repository, run a simple

mvn package

mkdir $ES_DIR/plugins/elasticsearch-query-templates
cp target/releases/elasticsearch-query-templates-1.0-SNAPSHOT.zip $ES_DIR/plugins/elasticsearch-query-templates

unzip $ES_DIR/plugins/elasticsearch-query-templates/elasticsearch-query-templates.zip

Usage

In the simplest case, submit both, template_string and template_vars as part of your search request:

GET _search
{
    "query": {
        "template": {
            "template_string": "{\"match_{{template}}\": {}}\"",
            "template_vars" : {
                "template" : "all"
            }
        }
    }
}

You register a template by storing it in the conf/scripts directory of elasticsearch. In order to execute the stored template execute a request like so:

GET _search
{
    "query": {
        "template": {
            "template_string": "storedTemplate",
            "template_vars" : {
                "template" : "all"
            }
        }
    }
}

Template language

Templating is based on Mustache. Some simple usage examples:

Substitution of tokens:

            "template_string": "{\"match_{{template}}\": {}}\"",
            "template_vars" : {
                "template" : "all"

License

Licensed to Elasticsearch under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Elasticsearch licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Elasticsearch plugin to support query templates (deprecated)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages