Unable to create template with Analyzer

Hello,

I was able to create an analyzer and use it on a single Index. Now, I would like to apply this to an Index template, so that whenever a new index (with Date attached to it) is created, this analyzer can be applied.

When trying to create the template it is giving me an error. Clearly something I am doing is not correct, but just could not figure out what..

PUT _template/textstrings

{
  "index_patterns": ["*event.abc.v1*"],
"settings": {
  "index": {
    "analysis": {
      "filter": {
        "ngram_filter": {
          "type": "nGram",
          "min_gram": "3",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "title_analyzer": {
	          "type" : "custom",
	          "tokenizer": "standard",
          "filter": ["ngram_filter"]
        }
      }
    }
  }
},
"mappings": {
  "doc": {
    "properties": {
      "content": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "title_analyzer"
          }
        }
      }
    }
  }
}
}

The error I receive is the following:

{
  "error": {
    "root_cause": [
      {
        "type": "not_x_content_exception",
        "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
      }
    ],
    "type": "not_x_content_exception",
    "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
  },
  "status": 500
}

Thanks to take a look.

Best regards

Hello ... any possible help here ?

You have a blank line been the PUT _template and the json. Which makes it fail I think.

This works well on my end:

PUT _template/textstrings
{
  "index_patterns": ["*event.abc.v1*"],
"settings": {
  "index": {
    "analysis": {
      "filter": {
        "ngram_filter": {
          "type": "nGram",
          "min_gram": "3",
          "max_gram": "20"
        }
      },
      "analyzer": {
        "title_analyzer": {
	          "type" : "custom",
	          "tokenizer": "standard",
          "filter": ["ngram_filter"]
        }
      }
    }
  }
},
"mappings": {
  "doc": {
    "properties": {
      "content": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "title_analyzer"
          }
        }
      }
    }
  }
}
}

Thanks a lot. Looks like it was an issue. Once I have removed the space, it fails with a different error:

    {
  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: template is missing;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: template is missing;"
  },
  "status": 400
}

Strange that it has worked on your end. I have checked the text and is the same. So, not sure what is missing

Probably you are using a 5.x version

Yes. I am using version 5.6 version.

So read the docs for your version: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-templates.html

Thanks a lot David. My bad on that. I have tried so many combinations before posting the issue here, that I forgot that I might have used the syntax of other versions.

It works now.

Thanks for your help.

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