elasticsearch 如何在弹性搜索6.5中更快地获取索引?,elasticsearch,java-8,elasticsearch,Java 8" /> elasticsearch 如何在弹性搜索6.5中更快地获取索引?,elasticsearch,java-8,elasticsearch,Java 8" />

elasticsearch 如何在弹性搜索6.5中更快地获取索引?

elasticsearch 如何在弹性搜索6.5中更快地获取索引?,elasticsearch,java-8,elasticsearch,Java 8,如何更快地获取索引。对我来说,检索所有索引需要2秒钟。有没有更快的方法?运行此行时,您可以尝试缓存来自Elasticsearch的响应: RestHighLevelClient client GetIndexRequest request = new GetIndexRequest().indices("*"); GetIndexResponse response = null; try { response = client.indices().get(

如何更快地获取索引。对我来说,检索所有索引需要2秒钟。有没有更快的方法?

运行此行时,您可以尝试缓存来自Elasticsearch的响应:

RestHighLevelClient client    

GetIndexRequest request = new GetIndexRequest().indices("*");
GetIndexResponse response = null;

try {
    response = client.indices().get(request, RequestOptions.DEFAULT);
}
catch (IOException e) {
    log.error("Unable to connect with Elasticsearch {}", e);
}

String indices[] = response.getIndices();
如果这段代码被多次调用,那么2秒可能是一个耗时的解决方案。将响应(索引名称)存储在缓存中并从缓存中获取响应将花费不到2秒的时间


仅当您的代码未在Elasticsearch集群中创建任何新索引且此代码部分被多次调用时,我才建议使用此解决方案。

运行此行时,您可以尝试缓存来自Elasticsearch的响应:

RestHighLevelClient client    

GetIndexRequest request = new GetIndexRequest().indices("*");
GetIndexResponse response = null;

try {
    response = client.indices().get(request, RequestOptions.DEFAULT);
}
catch (IOException e) {
    log.error("Unable to connect with Elasticsearch {}", e);
}

String indices[] = response.getIndices();
如果这段代码被多次调用,那么2秒可能是一个耗时的解决方案。将响应(索引名称)存储在缓存中并从缓存中获取响应将花费不到2秒的时间

仅当您的代码未在Elasticsearch集群中创建任何新索引且此代码部分被多次调用时,我才建议使用此解决方案。

请参阅:请参阅: