`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_

        :arg id: The id of the stored search template
        :arg body: The search definition template and its params
767960
def render_search_template(self, id=None, body=None, params=None):
        
        return self.transport.perform_request(
            "GET", _make_path("_render", "template", id), params=params, body=body
        )
545385
async def _has_id(self, *args, **kwds):
        
        # if there is only one positional argument
        if len(args) == 1:
            # parse the appropriate query
            result = await parse_string(
                self._query,
                self.service.object_resolver,
                self.service.connection_resolver,
                self.service.mutation_resolver,
                obey_auth=False
            )
            # go to the bottom of the result for the list of matching ids
            return self._find_id(result['data'], args[0])
        # otherwise
        else:
            # treat the attribute like a normal filter
            return self._has_id(**kwds)
837878
String spanIndexTemplate() {
    String result =
        "{\n"
            + "  \"TEMPLATE\": \"${__INDEX__}:"
            + SPAN
            + "-*\",\n"
            + "  \"settings\": {\n"
            + "    \"index.number_of_shards\": ${__NUMBER_OF_SHARDS__},\n"
            + "    \"index.number_of_replicas\": ${__NUMBER_OF_REPLICAS__},\n"
            + "    \"index.requests.cache.enable\": true,\n"
            + "    \"index.mapper.dynamic\": false,\n"
            + "    \"analysis\": {\n"
            + "      \"analyzer\": {\n"
            + "        \"traceId_analyzer\": {\n"
            + "          \"type\": \"custom\",\n"
            + "          \"tokenizer\": \"keyword\",\n"
            + "          \"filter\": \"traceId_filter\"\n"
            + "        }\n"
            + "      },\n"
            + "      \"filter\": {\n"
            + "        \"traceId_filter\": {\n"
            + "          \"type\": \"pattern_capture\",\n"
            + "          \"patterns\": [\"([0-9a-f]{1,16})$\"],\n"
            + "          \"preserve_original\": true\n"
            + "        }\n"
            + "      }\n"
            + "    }\n"
            + "  },\n";
    if (searchEnabled) {
      return result
          + ("  \"mappings\": {\n"
              + "    \"_default_\": {\n"
              + "      DISABLE_ALL" // don't concat all fields into big string
              + "      \"dynamic_templates\": [\n"
              + "        {\n"
              + "          \"strings\": {\n"
              + "            \"mapping\": {\n"
              + "              KEYWORD,\n"
              + "              \"ignore_above\": 256\n"
              + "            },\n"
              + "            \"match_mapping_type\": \"string\",\n"
              + "            \"match\": \"*\"\n"
              + "          }\n"
              + "        }\n"
              + "      ]\n"
              + "    },\n"
              + "    \""
              + SPAN
              + "\": {\n"
              + "      \"_source\": {\"excludes\": [\"_q\"] },\n"
              + "      \"properties\": {\n"
              + "        \"traceId\": ${__TRACE_ID_MAPPING__},\n"
              + "        \"name\": { KEYWORD },\n"
              + "        \"localEndpoint\": {\n"
              + "          \"type\": \"object\",\n"
              + "          \"dynamic\": false,\n"
              + "          \"properties\": { \"serviceName\": { KEYWORD } }\n"
              + "        },\n"
              + "        \"remoteEndpoint\": {\n"
              + "          \"type\": \"object\",\n"
              + "          \"dynamic\": false,\n"
              + "          \"properties\": { \"serviceName\": { KEYWORD } }\n"
              + "        },\n"
              + "        \"timestamp_millis\": {\n"
              + "          \"type\":   \"date\",\n"
              + "          \"format\": \"epoch_millis\"\n"
              + "        },\n"
              + "        \"duration\": { \"type\": \"long\" },\n"
              + "        \"annotations\": { \"enabled\": false },\n"
              + "        \"tags\": { \"enabled\": false },\n"
              + "        \"_q\": { KEYWORD }\n"
              + "      }\n"
              + "    }\n"
              + "  }\n"
              + "}");
    }
    return result
        + ("  \"mappings\": {\n"
            + "    \"_default_\": { DISABLE_ALL },\n"
            + "    \""
            + SPAN
            + "\": {\n"
            + "      \"properties\": {\n"
            + "        \"traceId\": ${__TRACE_ID_MAPPING__},\n"
            + "        \"annotations\": { \"enabled\": false },\n"
            + "        \"tags\": { \"enabled\": false }\n"
            + "      }\n"
            + "    }\n"
            + "  }\n"
            + "}");
  }
1050700
def Search(self,key):
		

		results = []
		for template in self.templates:
			if template.id.lower().find(key.lower()) != -1:  results.append(template)
			elif template.name.lower().find(key.lower()) != -1:  results.append(template)

		return(results)
204208
def get(self, arg):
        
        try:
            reservations = self.get_all_instances(filters={'tag:Name': [arg]})
            instance = reservations[0].instances[0]
        except IndexError:
            try:
                instance = self.get_all_instances([arg])[0].instances[0]
            except (_ResponseError, IndexError):
                # TODO: encapsulate actual exception for debugging
                err = "Can't find any instance with name or ID '%s'" % arg
                raise ValueError(err)
        return instance
1071423
def find(id)
      raise ArgumentError.new("Missing id/slug") unless id

      result = access_token.get("#{API_BASE}#{self.class::API_PATH}#{id}")
      raise ServiceError.new(result.code, result.body) unless result.code == "200"

      self.class::ITEM_CLASS.new(result.body)
    end
1065480
function createElasticsearch (args, model) {
    // get client - throw error if not set
    var elasticsearchClient = model.elasticsearch()
    // document to store in elastic search
    var body
    // use raw data to build body
    if (args.raw) {
        body = elasticSearchBodyFromRaw(model, args.raw)
    }
    // use record to build body
    else if (args.record) {
        body = elasticSearchBodyFromRecord(model, args.record)
    }
    else {
        // ignore errors
        return
    }
    // get id from originalId or id
    var id = body.originalId || body.id
    // if instance does not have id cannot store
    if (!id) {
        // ignore errors
        return
    }
    // get record type
    var type = model.esType
        ? _.get(body.data, model.esType) || model.name
        : model.name
    // if record is deleted then delete from elasticsearch
    if (body.isDeleted) {
        return elasticsearchClient.delete({
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
    // otherwise create/update record with elasticsearch
    else {
        return elasticsearchClient.index({
            body: body,
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
}
1216130
def fromPostArgs(cls, args):
        
        self = cls()

        # Partition into "openid." args and bare args
        openid_args = {}
        for key, value in args.items():
            if isinstance(value, list):
                raise TypeError("query dict must have one value for each key, "
                                "not lists of values.  Query is %r" % (args,))


            try:
                prefix, rest = key.split('.', 1)
            except ValueError:
                prefix = None

            if prefix != 'openid':
                self.args[(BARE_NS, key)] = value
            else:
                openid_args[rest] = value

        self._fromOpenIDArgs(openid_args)

        return self
258458
def extract_id(*object_types):
    

    def outer(func):
        def inner(*args, **kwargs):
            def id_of(x):
                return x.id if type(x) in object_types else x

            new_args = [id_of(arg) for arg in args]
            new_kwargs = {k: id_of(v) for k, v in kwargs.items()}
            return func(*new_args, **new_kwargs)

        return inner

    return outer
206258
def get_template(template_id, options = {})
      content_type = { 'Content-Type' => 'application/json' }
      content_type.merge(options[:headers]) if options[:headers]

      uri = build_uri("/accounts/#{acct_id}/templates/#{template_id}")

      http = initialize_net_http_ssl(uri)
      request = Net::HTTP::Get.new(uri.request_uri, headers(content_type))
      response = http.request(request)
      generate_log(request, response, uri)
      JSON.parse(response.body)
    end
1175150
def get_template(template_id,**kwargs):
    
    try:
        tmpl_i = db.DBSession.query(Template).filter(Template.id==template_id).options(joinedload_all('templatetypes.typeattrs.default_dataset.metadata')).one()

        #Load the attributes.
        for tmpltype_i in tmpl_i.templatetypes:
            for typeattr_i in tmpltype_i.typeattrs:
                typeattr_i.attr

        return tmpl_i
    except NoResultFound:
        raise HydraError("Template %s not found"%template_id)
1028417
def template(*args, **kwargs):
    
    tpl = args[0] if args else None
    for dictarg in args[1:]:
        kwargs.update(dictarg)
    adapter = kwargs.pop('template_adapter', SimpleTemplate)
    lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)
    tplid = (id(lookup), tpl)
    if tplid not in TEMPLATES or DEBUG:
        settings = kwargs.pop('template_settings', {})
        if isinstance(tpl, adapter):
            TEMPLATES[tplid] = tpl
            if settings: TEMPLATES[tplid].prepare(**settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings)
        else:
            TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings)
    if not TEMPLATES[tplid]:
        abort(500, 'Template (%s) not found' % tpl)
    return TEMPLATES[tplid].render(kwargs)
29623
public void addTemplateId(String id, Integer index) throws HelloSignException {
        List<String> currentList = getList(String.class, TEMPLATE_IDS);
        if (index == null) {
            index = currentList.size();
        } else if (index < 0) {
            throw new HelloSignException("index cannot be negative");
        } else if (index > currentList.size()) {
            throw new HelloSignException("index is greater than template ID list size: " + currentList.size());
        }
        if (index == currentList.size()) {
            add(TEMPLATE_IDS, id); // Just append the item
        } else {
            // Insert the item at the given index
            clearList(TEMPLATE_IDS);
            int limit = currentList.size(); // We'll be adding one
            for (int i = 0; i < limit + 1; i++) {
                if (i == index) {
                    add(TEMPLATE_IDS, id);
                }
                if (i < limit) {
                    add(TEMPLATE_IDS, currentList.get(i));
                }
            }
        }
    }
630052
def submitTemplate(id, data={}):
        
        conn = Qubole.agent()
        path = str(id) + "/run"
        return conn.post(Template.element_path(path), data)
804380
def es_query_template(path):
    

    if not is_text(path):
        Log.error("expecting path to be a string")

    if path != ".":
        f0 = {}
        f1 = {}
        output = wrap({
            "query": es_and([
                f0,
                {"nested": {
                    "path": path,
                    "query": f1,
                    "inner_hits": {"size": 100000}
                }}
            ]),
            "from": 0,
            "size": 0,
            "sort": []
        })
        return output, wrap([f0, f1])
    else:
        f0 = {}
        output = wrap({
            "query": es_and([f0]),
            "from": 0,
            "size": 0,
            "sort": []
        })
        return output, wrap([f0])
435788
def index(request, template_name="index.html"):
    
    if request.GET.get('ic-request'):
        counter, created = Counter.objects.get_or_create(pk=1)
        counter.value += 1
        counter.save()
    else:
        counter, created = Counter.objects.get_or_create(pk=1)
        print(counter.value)
    context = dict(
        value=counter.value,
    )
    return render(request, template_name, context=context)
1009761
def index_template_delete(name, hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)
    try:
        result = es.indices.delete_template(name=name)

        return result.get('acknowledged', False)
    except elasticsearch.exceptions.NotFoundError:
        return True
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot delete template {0}, server returned code {1} with message {2}".format(name, e.status_code, e.error))