# Filter\_path usage

**URL:** <https://discuss.elastic.co/t/filter-path-usage/193054>\
**Category:** Elasticsearch\
**Created:** [July 31, 2019, 7:38am UTC](https://discuss.elastic.co/t/filter-path-usage/193054 "2019-07-31T07:38:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubpa](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@rubpa](https://discuss.elastic.co/u/rubpa)\
**Post date:** [July 31, 2019, 7:38am UTC](https://discuss.elastic.co/t/filter-path-usage/193054/1 "2019-07-31T07:38:51Z")

</div>

I have used [templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) to tune the number of replicas and over time I've a number of templates. I don't remember the exact names.

`GET _template` gives very verbose output because of a huge number of internal templates (starting with .). I tried [filter\_path](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering) but could not figure out how to use it to show only the level 1 names of the json output. e.g.

```
{
  "template1",
  "template2",
  ".watch...",
  ".monitoring..."
}

```

Additionally, how can I filter out the internal templates i.e. not show templates starting with a dot?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 1, 2019, 12:45pm UTC](https://discuss.elastic.co/t/filter-path-usage/193054/2 "2019-08-01T12:45:37Z")

</div>

As you have to specify a certain field in the `filter_path` to filter for, and those fields are dynamic I am afraid that `filter_path` is not the best way to go here.

There is a swiss army knife named [jq](https://stedolan.github.io/jq/) for processing json on the command line, and you can use it like this to only extract the keys

```auto
curl 'localhost:9200/_template?pretty' | jq 'keys'

```

--Alex

---

<div class="post-metadata">

**Author:** ![rubpa](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@rubpa](https://discuss.elastic.co/u/rubpa)\
**Post date:** [August 6, 2019, 10:35am UTC](https://discuss.elastic.co/t/filter-path-usage/193054/3 "2019-08-06T10:35:05Z")

</div>

Thanks Alex! I was not aware of jq - looks powerful. However need to use the command line instead of dev tools console.

I also discovered [cat templates](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/cat-templates.html) which gives a much cleaner output that I can use to discover my templates.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 6, 2019, 12:04pm UTC](https://discuss.elastic.co/t/filter-path-usage/193054/4 "2019-08-06T12:04:04Z")

</div>

`jq` is a commandline tool, but the cat templates API is indeed the better solution. fully forgot about that for a second 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 3, 2019, 12:04pm UTC](https://discuss.elastic.co/t/filter-path-usage/193054/5 "2019-09-03T12:04:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
