-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Inconsistent behavior of ignoreUnavailable
on closed Indices
#20105
Comments
Hi @JD557 sorry it has taken a while to get back to you on this but can you please share your java api code? |
I don't really have a Java API code (I use a elastic4s, which is a Java API wrapper). Nevertheless, here's my scala specs2 test that I used to reproduce this problem: "silently ignore failures" in {
val f = for {
_ <- client.execute(index into "deleted-index" -> "t" fields ("test" -> "deleted"))
_ <- client.execute(index into "closed-index" -> "t" fields ("test" -> "closed"))
_ <- client.execute(index into "open-index" -> "t" fields ("test" -> "open"))
_ <- client.execute(delete index "deleted-index")
ff <- client.execute(close index "closed-index")
} yield ff
Await.result(f, 60.seconds) // Hackish way to make sure that everything was executed
val ignoreUnavailable = IndicesOptions.fromOptions(
true, // ignoreUnavailable
true, // allowNoIndices
true, // expandToOpenIndices
false // expandToClosedIndices
)
// Make sure that closed indices are not forbidden
ignoreUnavailable.forbidClosedIndices() === false
// Normal queries should fail on unknown, deleted and closed indices
client.execute(search in "unknown-index" -> "t") must throwAn[Exception].await // PASS
client.execute(search in "deleted-index" -> "t") must throwAn[Exception].await // PASS
client.execute(search in "closed-index" -> "t") must throwAn[Exception].await // PASS
// Normal queries should fail on unknown, deleted and closed indices
client.execute(search in "open-index" -> "t") must not(throwAn[Exception]).await // PASS
// Queries with custom flags should succeed on unknown, deleted and closed indices
client.execute(search in "unknown-index" -> "t" indicesOptions ignoreUnavailable) must not(throwAn[Exception]).await // PASS
client.execute(search in "deleted-index" -> "t" indicesOptions ignoreUnavailable) must not(throwAn[Exception]).await // PASS
client.execute(search in "closed-index" -> "t" indicesOptions ignoreUnavailable) must not(throwAn[Exception]).await // FAIL
} |
heya @JD557 the problem is caused by setting |
Thanks for your response. I think that either you misunderstood my post or I misunderstood yours: Are you saying that there's no way to get the same behavior using the Java API? Can I only either get an Exception or a cluster block? If that's not the case (and it's possible to perform a query equivalent to the REST API), then I need to ask another question:
Just to make things clear, I'm not setting it to As you might be aware, it's "impossible" to set the value of So, to get a query equivalent to the REST API, which predefined |
You are right, I didn't notice that you weren't setting We are planning to revisit the indices options as they expose some internal bits to the Java API which is not desirable. See #9438. We will take this into account for sure. |
Elasticsearch version: 2.3.4
JVM version: 1.8.0_66
OS version: Tested on the official elasticsearch docker image and on Mac OS X 10.11.6
Description of the problem including expected versus actual behavior:
Executing a search query to a closed index with the
ignoreUnavailable
flag set totrue
works via the HTTP interface, yet it fails if the request is done via the Java API (it seems to work as expected for non-existent indices).Steps to reproduce:
http://<host>:<port>/closed_index/_search?ignore_unavailable
). The request will be successful.IndicesOptions.fromOptions(true, true, true, false)
orIndicesOptions.lenientExpandOpen()
). The request will fail with a[FORBIDDEN/4/index closed]
.The text was updated successfully, but these errors were encountered: