Resolving wildcard index names in ES 2.0


(Craig Ching) #1

Hi all,

I'm trying to convert this code:

String[] indices = client.admin().cluster().prepareState().execute().actionGet()
                               .getState().getMetaData()
                               .convertFromWildcards(match, IndicesOptions.lenientExpandOpen());

to ES 2.0. I see IndexNameExpressionResolve and WildcardExpressionResolver, but I can't seem to find a good way to instantiate these.

Anyone know how I can do this? I'm trying to resolve a bunch of indexes from a pattern to their concrete names if that isn't obvious from the code.

I appreciate any help!

Cheers,
Craig


(Craig Ching) #2

So I think I've resolved this, I'd like to share what I did and see if anyone can review and let me know if it's the expected way to do it.

Here's what I came up with:

IndexNameExpressionResolver resolver = new IndexNameExpressionResolver(Settings.EMPTY);
String [] indices = resolver.concreteIndices(cl.admin()
    .cluster().prepareState().get().getState(),
    IndicesOptions.lenientExpandOpen(),
        match);

Does that look like the idiomatic way to resolve index names based on a wildcard expression for ES 2.0? I guess I feel that with the @Inject annotation on IndexNameExpressionResolver and having to send in Settings.EMPTY, something just doesn't feel right.

I appreciate any responses!


(system) #3