IndexExists() with wildcard index name always returns true after upgrading to NEST 5.4.0


(j.qin@thegordiangroup.com) #1

Hi, I had the following code that used to work in NEST 2.4.1 and Elasticsearch 2.3.1 :
var indices = Indices.Index("prefix*");
while (myClient.IndexExists(indices).Exists) {
//code to delete them
}
I recently upgraded to NEST 5.4.0 and Elasticsearch 5.5.0, and the above code stopped working. The "while" condition is always true and the loop becomes infinite. (I've verified all indices are deleted.) Can anyone tell me why and how to check if indices with a specified prefix exist? Thanks a lot!


(Russ Cam) #2

Sadly, this is a bug in Elasticsearch that is due to be fixed in the next release. It's closely related to changes as part of

and

In the meantime, if you're rolling with the default behaviour of the client to not throw exceptions, simply issuing

client.DeleteIndex("prefix*");

will be sufficient to delete the indices, even if they don't exist.


(Jason Tedor) #3

I initially told @forloop this is a bug but after doing my due diligence here, I'm now going to say that is not and this behavior is intended (so sorry for any confusion this causes you). Instead, to obtain the behavior that you are desiring you should add the parameter allow_no_indices=false to the REST request. Yes, this is change from previous behavior for HEAD where this was not necessary but it was a bug that HEAD and GET behaved differently. They are aligned now so, and the behavior you're looking for ways always present on GET with allow_no_indices=false. I hope that helps clarify the situation for you.


(system) #4

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