Thanks,
Jôrg's tip didn't work. Null was not accepted in the constructor. We
might be using a different version of ElasticSearch.
However, I did find the 0.90.10 equivalent of the class Ivan suggested.
I'm guessing that's as close as I can get to reproducing the _alias
request. I tried to reproduce it this way (for some reason the action
listener version was not firing for me.. - must have missed something - so
I'm using actionGet() instead):
ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
.filterRoutingTable(true)
.filterNodes(true)
.filteredIndices(new String[]{});
clusterStateRequest.listenerThreaded(false);
client.admin().cluster().state(clusterStateRequest).actionGet().getState().metaData();
Sadly, it was not as fast as what I'm seeing with the curl statement. In
fact, the following call turned out to be faster than the one above and is
what I will be using for now. It's still about 40ms slower than the curl
_alias call, but it's better than the 80ms I was getting with my initial
query. :)
client.admin().indices().prepareStats().clear().get().getIndices();
On Tuesday, January 21, 2014 2:59:11 PM UTC-5, Ivan Brusic wrote:
>
> The easiest way to find out how to use the Java API equivalent of a REST
> call is to simply look up the RestAction class. In this case:
>
>
> https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetIndicesAliasesAction.java<https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetIndicesAliasesAction.java?source=c>
>
> I am on version 0.90.2 and I have been using
> client.admin().cluster().state(new
> ClusterStateRequest()).actionGet().getState().getMetaData().aliases()
> which should be equivalent to yours.
>
> Cheers,
>
> Ivan
>
>
>
> On Mon, Jan 20, 2014 at 5:42 PM, Emilie Lavigne
> <[email protected]<javascript:>
> > wrote:
>
>> Is there a way to reproduce localhost:9200/_aliases using the java api?
>>
>> Our system often needs to request the list of indices available (our
>> indices are organized by date) to identify which days in the query date
>> range have a corresponding index. We are trying to avoid having to cache
>> the list since it may change as our content retention policy cleans up
>> indices.
>>
>> I can retrieve the indices using the following java api call (equivalent
>> of curl localhost:9200/_cluster/state):
>>
>>
>> client.admin().cluster().prepareState().execute().actionGet().getState().metaData()
>>
>>
>> However on our cluster, this call can take up to 80ms, while the curl get
>> request for aliases comes back in 15ms. Obviously, we would prefer to use
>> the latter since the response time is compounded with the search time. I
>> just can't seem to find a way to get that list using java.
>>
>> I've tried this, but the ImmutableOpenMap always comes back empty:
>>
>> ImmutableOpenMap<String, List<AliasMetaData>> aliases =
>> client.admin().indices().getAliases(new
>> IndicesGetAliasesRequest()).actionGet().getAliases();
>>
>>
>> Any suggestions?
>>
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "elasticsearch" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elasticsearch/f91edcaf-5ce9-4d92-9aa0-61bd530a21d4%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/566e74a3-8419-42d7-8d16-20ccaecab461%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.