Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simulate template composition API _index_template/_simulate_index/{name} #55686

Merged
merged 28 commits into from Apr 29, 2020

Conversation

andreidan
Copy link
Contributor

@andreidan andreidan commented Apr 23, 2020

This adds a new api to simulate matching the given index name against the
index templates in the system.

The syntax for the new API takes the following form:

POST _index_template/_simulate_index/{index_name}
{
  "index_patterns": ["logs-*"],
  "priority": 15,
  "template": {
	"settings": {
		"number_of_shards": 3
	}
       ...
   }
}

Where the body is optional, but we support the entire body used by the
PUT _index_template/{name} api. When the body is specified we'll simulate
matching the given index against a system that'd have the given index
template together with the index templates that exist in the system.

The response, in both cases, will return the matching template's resolved
settings, mappings and aliases, together with a special field that'll print any
overlapping templates and their corresponding index patterns.

Relates to #53101

This adds a new api to simulate matching the given index name against the
 index templates in the system.
@andreidan andreidan added :Data Management/Indices APIs APIs to create and manage indices and templates v8.0.0 v7.8.0 labels Apr 23, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

@andreidan
Copy link
Contributor Author

@elasticmachine update branch

@andreidan andreidan requested a review from dakrone April 24, 2020 13:43
@andreidan andreidan marked this pull request as ready for review April 24, 2020 13:52
@martijnvg martijnvg mentioned this pull request Apr 24, 2020
39 tasks
@andreidan andreidan changed the title Add _index_template/_simulate_index/{name} api Add simulate template composition API _index_template/_simulate_index/{name} Apr 24, 2020
@dakrone
Copy link
Member

dakrone commented Apr 24, 2020

@andreidan how would you feel about removing the "Post" prefix from the actions and class names? I think it sounds a little strange to call it PostSimulateIndexTemplate* rather than just SimulateIndexTemplate*, and I'd prefer to remove the prefix.

@andreidan
Copy link
Contributor Author

@andreidan how would you feel about removing the "Post" prefix from the actions and class names? I think it sounds a little strange to call it PostSimulateIndexTemplate* rather than just SimulateIndexTemplate*, and I'd prefer to remove the prefix.

Sure thing

@andreidan
Copy link
Contributor Author

@dakrone renamed the classes

@andreidan
Copy link
Contributor Author

@dakrone I think this is ready for review (removed the post_ prefix from the action names too)

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this Andrei! I left some comments about it

andreidan and others added 5 commits April 27, 2020 11:13
Co-Authored-By: Lee Hinman <dakrone@users.noreply.github.com>
Co-Authored-By: Lee Hinman <dakrone@users.noreply.github.com>
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andreidan! I left a couple more comments, but overall looks good!

@andreidan
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for iterating on this Andrei! I left one more comment about adding a test that also uses composed_of (to make sure we resolve everything when simulating)

@andreidan
Copy link
Contributor Author

@elasticmachine update branch

@andreidan
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@andreidan andreidan merged commit 1a5845e into elastic:master Apr 29, 2020
andreidan added a commit to andreidan/elasticsearch that referenced this pull request Apr 29, 2020
…/{name} (elastic#55686)

This adds a new api to simulate matching the given index name against the
 index templates in the system.

The syntax for the new API takes the following form:

POST _index_template/_simulate_index/{index_name}
{
  "index_patterns": ["logs-*"],
  "priority": 15,
  "template": {
	"settings": {
		"number_of_shards": 3
	}
       ...
   }
}

Where the body is optional, but we support the entire body used by the
PUT _index_template/{name} api. When the body is specified we'll simulate
matching the given index against a system that'd have the given index
template together with the index templates that exist in the system.

The response, in both cases, will return the matching template's resolved
settings, mappings and aliases, together with a special field that'll print any
overlapping templates and their corresponding index patterns.

(cherry picked from commit 1a5845e)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
andreidan added a commit that referenced this pull request Apr 29, 2020
…_index/{name} (#55686) (#55922)

This adds a new api to simulate matching the given index name against the
 index templates in the system.

The syntax for the new API takes the following form:

POST _index_template/_simulate_index/{index_name}
{
  "index_patterns": ["logs-*"],
  "priority": 15,
  "template": {
	"settings": {
		"number_of_shards": 3
	}
       ...
   }
}

Where the body is optional, but we support the entire body used by the
PUT _index_template/{name} api. When the body is specified we'll simulate
matching the given index against a system that'd have the given index
template together with the index templates that exist in the system.

The response, in both cases, will return the matching template's resolved
settings, mappings and aliases, together with a special field that'll print any
overlapping templates and their corresponding index patterns.

(cherry picked from commit 1a5845e)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
andreidan added a commit to andreidan/elasticsearch that referenced this pull request Apr 29, 2020
As elastic#55686 was backported the simulate index template api is no available
in 7.8.
andreidan added a commit that referenced this pull request May 5, 2020
As #55686 was backported the simulate index template api is no available
in 7.8.
dakrone added a commit to dakrone/elasticsearch that referenced this pull request May 15, 2020
This adds an API for simulating template composition with or without an index template.

It looks like:

```
POST /_index_template/_simulate/my-template
```

To simulate a template named `my-template` that already exists, or, to simulate a template that does
not already exist:

```
POST /_index_template/_simulate
{
  "index_patterns": ["my-index"]
  "composed_of": ["ct1", "ct2"],
}
```

This is related to elastic#55686, which adds an API to simulate composition based on an index name (hence
the `_simulate_index` vs `_simulate`).

This commit also adds reference documentation for both simulation APIs.

Relates to elastic#53101
Resolves elastic#56390
Resolves elastic#56255
dakrone added a commit that referenced this pull request May 18, 2020
This adds an API for simulating template composition with or without an index template.

It looks like:

```
POST /_index_template/_simulate/my-template
```

To simulate a template named `my-template` that already exists, or, to simulate a template that does
not already exist:

```
POST /_index_template/_simulate
{
  "index_patterns": ["my-index"]
  "composed_of": ["ct1", "ct2"],
}
```

This is related to #55686, which adds an API to simulate composition based on an index name (hence
the `_simulate_index` vs `_simulate`).

This commit also adds reference documentation for both simulation APIs.

Relates to #53101
Resolves #56390
Resolves #56255
dakrone added a commit to dakrone/elasticsearch that referenced this pull request May 18, 2020
…tic#56842)

This adds an API for simulating template composition with or without an index template.

It looks like:

```
POST /_index_template/_simulate/my-template
```

To simulate a template named `my-template` that already exists, or, to simulate a template that does
not already exist:

```
POST /_index_template/_simulate
{
  "index_patterns": ["my-index"]
  "composed_of": ["ct1", "ct2"],
}
```

This is related to elastic#55686, which adds an API to simulate composition based on an index name (hence
the `_simulate_index` vs `_simulate`).

This commit also adds reference documentation for both simulation APIs.

Relates to elastic#53101
Resolves elastic#56390
Resolves elastic#56255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >feature v7.8.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants