Template analyzer whitespace

Hi,
With this tempalte:

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:

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

and my output is:

{
  "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:

{
  "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?

Hey,

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

--Alex

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

try this

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"
      }
    }
  }
}

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