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

indices starting with - (dash) cause problems if used with wildcards #19800

Closed
yehosef opened this issue Aug 4, 2016 · 7 comments
Closed

indices starting with - (dash) cause problems if used with wildcards #19800

yehosef opened this issue Aug 4, 2016 · 7 comments
Assignees
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates

Comments

@yehosef
Copy link

yehosef commented Aug 4, 2016

I was looking through the indices on one of our hosts and saw some indices that started with - (dash), eg "-2016.04.15". I'm not sure why it was there - but not to critical, elasticsearch lets you do it.

POST -2016.12.12/test
{
  "name":"abc"
}

I tried to delete these indices by issuing
DELETE -2016.*

The problem is that this was interpreted as
DELETE everything except for indices starting with 2016.
which basically means delete the entire database - and after a few poignant seconds, that's what it did.

I have since become acquainted with https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html and the ability to include or exclude indices with the + or - operator, but it seems that this is more dangerous than useful, at least if you are unfortunate enough to have indices that start with -.

I understand that it's a "feature", but it doesn't seems practically so useful. Perhaps there could be a special query string for DELETE like "wildcard=inclusive" or "=exclusive"... As it is now, I'm not even sure how I would delete the indices that start with "-2016." I can't do "+-2016.*"

@clintongormley
Copy link

So curiously, you can DELETE -whole_index_name. It's only if you specify the wildcard that the +/- behaviour kicks in. This in itself sounds like a bug.

In order to remove ambiguity, I think we should prevent index names starting with + or -.

Related #9059

@clintongormley clintongormley added >bug discuss :Data Management/Indices APIs APIs to create and manage indices and templates labels Aug 4, 2016
@yehosef
Copy link
Author

yehosef commented Aug 4, 2016

yes.. that would be fine.

@colings86
Copy link
Contributor

Discussed in Fix It Friday and we agreed that we should fix the bug that the +/- behaviour does not work unless there is a wildcard, and also prevent index names starting with a + or -

@colings86 colings86 added help wanted adoptme and removed discuss labels Aug 5, 2016
@makeyang
Copy link
Contributor

makeyang commented Aug 9, 2016

@colings86
I'd like to pull request for this issue. but I have some questions to ask:

  1. what do u mean by "the +/- behaviour does not work unless there is a wildcard", let's say I had only one index "twitter", and I delete with name "+twitter", what will happen? take as index not found or delete twitter?

@makeyang
Copy link
Contributor

makeyang commented Aug 9, 2016

@colings86
also is there anywhere ES define "wildcard"?

@yehosef
Copy link
Author

yehosef commented Aug 9, 2016

FWIW - the case of using an exclusion in the index name in the docs was together with an inclusion - +test*,-test3 I question the usefulness of an exclusion by itself. How often do you really want to do DELETE -test-* and doing a +test* is not needed, because it's inherently "+". You would just do DELETE test*

I would offer that because the implications of someone misunderstanding and and its questionable need, perhaps you should consider putting it in a query string option, then it's easier that it's more intentional. eg to do the command that would now be DELETE -test-*, instead do a DELETE *?exclude=test-*. Then it's much more obvious what you're doing but you still have the same power.

The truth is that this is really mainly a problem with DELETE, perhaps these changes should just be made here.

@yehosef
Copy link
Author

yehosef commented Aug 9, 2016

note - some of this discussion is still relevant even if you remove dashes from the start of queries. DELETE -test* is still just as dangerous and might not be obvious to some users what would happen.

@dakrone dakrone self-assigned this Aug 17, 2016
@dakrone dakrone removed the help wanted adoptme label Aug 17, 2016
dakrone added a commit to dakrone/elasticsearch that referenced this issue Aug 17, 2016
Previously this was possible, which was problematic when issuing a
request like `DELETE /-myindex`, which was interpretted as "delete
everything except for myindex".

Resolves elastic#19800
dakrone added a commit to dakrone/elasticsearch that referenced this issue Oct 12, 2016
There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in elastic#20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to elastic#19800
javanna pushed a commit to javanna/elasticsearch that referenced this issue Oct 17, 2016
There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in elastic#20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to elastic#19800
javanna pushed a commit that referenced this issue Oct 18, 2016
…20898)

* Only negate index expression on all indices with preceding wildcard

There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in #20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to #19800
javanna pushed a commit that referenced this issue Oct 18, 2016
…20898)

* Only negate index expression on all indices with preceding wildcard

There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in #20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to #19800
javanna pushed a commit that referenced this issue Oct 18, 2016
…20898)

* Only negate index expression on all indices with preceding wildcard

There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in #20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to #19800
javanna pushed a commit to javanna/elasticsearch that referenced this issue Oct 19, 2016
…lastic#20898)

* Only negate index expression on all indices with preceding wildcard

There is currently a very confusing behavior in Elasticsearch for the
following:

Given the indices: `[test1, test2, -foo1, -foo2]`

```
DELETE /-foo*
```

Will cause the `test1` and `test2` indices to be deleted, when what is
usually intended is to delete the `-foo1` and `-foo2` indices.

Previously we added a change in elastic#20033 to disallow creating indices
starting with `-` or `+`, which will help with this situation. However,
users may have existing indices starting with these characters.

This changes the negation to only take effect in a wildcard (`*`) has
been seen somewhere in the expression, so in order to delete `-foo1` and
`-foo2` the following now works:

```
DELETE /-foo*
```

As well as:

```
DELETE /-foo1,-foo2
```

so in order to actually delete everything except for the "foo" indices
(ie, `test1` and `test2`) a user would now issue:

```
DELETE /*,--foo*
```

Relates to elastic#19800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates
Projects
None yet
Development

No branches or pull requests

5 participants