# Template analyzer whitespace

**URL:** <https://discuss.elastic.co/t/template-analyzer-whitespace/178254>\
**Category:** Elasticsearch\
**Created:** [April 24, 2019, 12:53pm UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254 "2019-04-24T12:53:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Babak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babak/32/44723_2.png) [@Babak](https://discuss.elastic.co/u/Babak)\
**Post date:** [April 24, 2019, 12:53pm UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254/1 "2019-04-24T12:53:30Z")

</div>

Hi,  
With this tempalte:

```auto
PUT _template/test-analyzer
{
  "index_patterns" : [
      "test-analyzer"
    ],
    "settings" : {
      "index" : {
        "refresh_interval" : "5s",
        "number_of_shards" : "1",
        "number_of_replicas" : "1"
      },
      "analysis": {
        "analyzer": "whitespace"
      }
    }
}

```

I create new index `test-analyzer` and check it's setting and I see everything works fine.  
But when check the analyzer with index using this test:

```auto
GET test-analyzer/_analyze
{
  "text" : "/etc/elastic/search is mine"
}

```

and my output is:

```auto
{
  "tokens" : [
    {
      "token" : "etc",
      "start_offset" : 1,
      "end_offset" : 4,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "elastic",
      "start_offset" : 5,
      "end_offset" : 12,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "search",
      "start_offset" : 13,
      "end_offset" : 19,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "is",
      "start_offset" : 20,
      "end_offset" : 22,
      "type" : "<ALPHANUM>",
      "position" : 3
    },
    {
      "token" : "mine",
      "start_offset" : 23,
      "end_offset" : 27,
      "type" : "<ALPHANUM>",
      "position" : 4
    }
  ]
}

```

while my tokens must be like this:

```auto
{
  "tokens" : [
    {
      "token" : "/etc/elastic/search",
      "start_offset" : 0,
      "end_offset" : 19,
      "type" : "word",
      "position" : 0
    },
    {
      "token" : "is",
      "start_offset" : 20,
      "end_offset" : 22,
      "type" : "word",
      "position" : 1
    },
    {
      "token" : "mine",
      "start_offset" : 23,
      "end_offset" : 27,
      "type" : "word",
      "position" : 2
    }
  ]
}

```

Is there any misconfiguration here?

---

<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:** [April 25, 2019, 6:39am UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254/2 "2019-04-25T06:39:31Z")

</div>

Hey,

just to make sure there are no misunderstandings: What is your intention here?

--Alex

---

<div class="post-metadata">

**Author:** ![Babak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babak/32/44723_2.png) [@Babak](https://discuss.elastic.co/u/Babak)\
**Post date:** [April 25, 2019, 10:07am UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254/3 "2019-04-25T10:07:25Z")

</div>

I want to set my default analyzer to whitespace for all new indices

---

<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:** [April 25, 2019, 2:50pm UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254/4 "2019-04-25T14:50:55Z")

</div>

try this

```auto
DELETE foo

PUT foo
{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type" : "whitespace"
        } 
      }
    }
  }
}

GET foo/_analyze
{
  "text" : "/etc/elastic/search is mine"
}

PUT foo/_doc/1?refresh
{
  "text" : "/etc/elastic/search is mine"
}

GET foo/_search
{
  "query": {
    "term": {
      "text": {
        "value": "/etc/elastic/search"
      }
    }
  }
}

```

---

<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:** [May 23, 2019, 2:50pm UTC](https://discuss.elastic.co/t/template-analyzer-whitespace/178254/5 "2019-05-23T14:50:57Z")

</div>

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