Skip to content

Index template creation fails when multiple index patterns are provided due to invalid comma-separated pattern handling #8738

@Botonomus9000

Description

@Botonomus9000

Elastic.Clients.Elasticsearch version:
8.17.4
Elasticsearch version:
8.17.4
.NET runtime version:
net8.0
Operating system version:
Windows 11 Enterprise 26100.6584

Description of the problem including expected versus actual behavior:
When creating an index template in Elasticsearch, I am passing multiple patterns to the IndexPattenrs property as an array (e.g., ["pattern-1-", "pattern-2"]). However, Elasticsearch treats these as a single string with a comma separating the patterns (e.g., "pattern-1-,pattern-2"), rather than as two distinct patterns. This results in a validation error and the index template does not get created because commas are not allowed in index names or patterns.

Steps to reproduce:

  1. Create an index template with more than one index pattern
var patternOne = "pattern-1-*";
var patternTwo = "pattern-2";
client.Indices.PutIndexTemplateAsync(indexTemplateName, it => it
   					.IndexPatterns(new[] { patternOne, patternTwo })
   					.Priority(priority)
   					.AllowAutoCreate(false)
   					.Template(t => t
   						.Settings(s => s
                               ...
   						.Mappings(m => m
                               ...
							)
   					)
   				)

Expected behavior
The index template is created with two index patterns in the index patterns array.

Example Error

Invalid Elasticsearch response built from a unsuccessful (400) low level call on PUT: /_index_template/a6c72323-sample-89123-v1-template
 Exception: Request failed to execute. Call: Status code 400 from: PUT /_index_template/a6c72323-sample-89123-v1-template. ServerError: Type: invalid_index_template_exception Reason: "index_template [a6c72323-sample-89123-v1-template] invalid, cause [Validation Failed: 1: index_pattern [a6c72323-sample-89123-v1-*,a6c72323-sample-89123-v1] must not contain a ',';2: index_pattern [a6c72323-sample-89123-v1-*,a6c72323-sample-89123-v1] must not contain the following characters ['/',',','|','>','?','*','<','"',' ','\'];]"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions