本文整理汇总了Java中org.elasticsearch.action.admin.indices.get.GetIndexRequest类的典型用法代码示例。如果您正苦于以下问题:Java GetIndexRequest类的具体用法?Java GetIndexRequest怎么用?Java GetIndexRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GetIndexRequest类属于org.elasticsearch.action.admin.indices.get包,在下文中一共展示了GetIndexRequest类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndexListWithPrefix
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
public List<String> getIndexListWithPrefix(Object object) {
LOG.info("Retrieving index list with prefix: {}", object.toString());
String[] indices = client.admin().indices().getIndex(new GetIndexRequest()).actionGet().getIndices();
ArrayList<String> indexList = new ArrayList<>();
int length = indices.length;
for (int i = 0; i < length; i++) {
String indexName = indices[i];
if (indexName.startsWith(object.toString())) {
indexList.add(indexName);
}
}
return indexList;
}
示例2: execute
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
/**
* Execute the ActionRequest and returns the REST response using the channel.
*/
public void execute() throws Exception {
ActionRequest request = requestBuilder.request();
//todo: maby change to instanceof multi?
if(requestBuilder instanceof JoinRequestBuilder){
executeJoinRequestAndSendResponse();
}
else if (request instanceof SearchRequest) {
client.search((SearchRequest) request, new RestStatusToXContentListener<SearchResponse>(channel));
} else if (requestBuilder instanceof SqlElasticDeleteByQueryRequestBuilder) {
throw new UnsupportedOperationException("currently not support delete on elastic 2.0.0");
}
else if(request instanceof GetIndexRequest) {
this.requestBuilder.getBuilder().execute( new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
}
else {
throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));
}
}
示例3: Elasticsearch2Schema
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
/**
* Creates an Elasticsearch2 schema.
*
* @param coordinates Map of Elasticsearch node locations (host, port)
* @param userConfig Map of user-specified configurations
* @param indexName Elasticsearch database name, e.g. "usa".
*/
Elasticsearch2Schema(Map<String, Integer> coordinates,
Map<String, String> userConfig, String indexName) {
super();
final List<InetSocketAddress> transportAddresses = new ArrayList<>();
for (Map.Entry<String, Integer> coordinate: coordinates.entrySet()) {
transportAddresses.add(
new InetSocketAddress(coordinate.getKey(), coordinate.getValue()));
}
open(transportAddresses, userConfig);
if (client != null) {
final String[] indices = client.admin().indices()
.getIndex(new GetIndexRequest().indices(indexName))
.actionGet().getIndices();
if (indices.length == 1) {
index = indices[0];
} else {
index = null;
}
} else {
index = null;
}
}
示例4: Elasticsearch5Schema
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
/**
* Creates an Elasticsearch5 schema.
*
* @param coordinates Map of Elasticsearch node locations (host, port)
* @param userConfig Map of user-specified configurations
* @param indexName Elasticsearch database name, e.g. "usa".
*/
Elasticsearch5Schema(Map<String, Integer> coordinates,
Map<String, String> userConfig, String indexName) {
super();
final List<InetSocketAddress> transportAddresses = new ArrayList<>();
for (Map.Entry<String, Integer> coordinate: coordinates.entrySet()) {
transportAddresses.add(
new InetSocketAddress(coordinate.getKey(), coordinate.getValue()));
}
open(transportAddresses, userConfig);
if (client != null) {
final String[] indices = client.admin().indices()
.getIndex(new GetIndexRequest().indices(indexName))
.actionGet().getIndices();
if (indices.length == 1) {
index = indices[0];
} else {
index = null;
}
} else {
index = null;
}
}
示例5: testMissingIndicesQuery
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testMissingIndicesQuery() throws FoxtrotException {
List<Document> documents = TestUtils.getQueryDocumentsDifferentDate(getMapper(), new Date(2014 - 1900, 4, 1).getTime());
documents.addAll(TestUtils.getQueryDocumentsDifferentDate(getMapper(), new Date(2014 - 1900, 4, 5).getTime()));
getQueryStore().save(TestUtils.TEST_TABLE_NAME, documents);
for (Document document : documents) {
getElasticsearchServer().getClient().admin().indices()
.prepareRefresh(ElasticsearchUtils.getCurrentIndex(TestUtils.TEST_TABLE_NAME, document.getTimestamp()))
.setForce(true).execute().actionGet();
}
GetIndexResponse response = getElasticsearchServer().getClient().admin().indices().getIndex(new GetIndexRequest()).actionGet();
assertEquals(3, response.getIndices().length);
Query query = new Query();
query.setLimit(documents.size());
query.setTable(TestUtils.TEST_TABLE_NAME);
BetweenFilter betweenFilter = new BetweenFilter();
betweenFilter.setField("_timestamp");
betweenFilter.setFrom(documents.get(0).getTimestamp());
betweenFilter.setTo(documents.get(documents.size() - 1).getTimestamp());
betweenFilter.setTemporal(true);
query.setFilters(Lists.<Filter>newArrayList(betweenFilter));
QueryResponse actualResponse = QueryResponse.class.cast(getQueryExecutor().execute(query));
assertEquals(documents.size(), actualResponse.getDocuments().size());
}
示例6: buildResponse
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
@Override
public RestResponse buildResponse(GetIndexResponse getIndexResponse, XContentBuilder builder) throws Exception {
GetIndexRequest.Feature[] features = getIndexRequest.features();
String[] indices = getIndexResponse.indices();
builder.startObject();
for (String index : indices) {
builder.startObject(index);
for (GetIndexRequest.Feature feature : features) {
switch (feature) {
case ALIASES:
writeAliases(getIndexResponse.aliases().get(index), builder, channel.request());
break;
case MAPPINGS:
writeMappings(getIndexResponse.mappings().get(index), builder, channel.request());
break;
case SETTINGS:
writeSettings(getIndexResponse.settings().get(index), builder, channel.request());
break;
default:
throw new IllegalStateException("feature [" + feature + "] is not valid");
}
}
builder.endObject();
}
builder.endObject();
return new BytesRestResponse(RestStatus.OK, builder);
}
示例7: getAllIndice
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
private List<String> getAllIndice() {
final List<String> indice = new LinkedList<String>();
final GetIndexResponse resp = client.admin().indices().getIndex(new GetIndexRequest()).actionGet();
for (final String indexName : resp.indices()) {
if (indexName.startsWith(props.getEsSpanIndexPrefix()) //
|| indexName.startsWith(props.getEsAnnotationIndexPrefix())) {
indice.add(indexName);
}
}
return indice;
}
示例8: getIndex
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
@Override
public ActionFuture<GetIndexResponse> getIndex(GetIndexRequest request) {
return execute(GetIndexAction.INSTANCE, request);
}
示例9: GetIndexRequestRestListener
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
public GetIndexRequestRestListener(RestChannel channel,GetIndexRequest getIndexRequest) {
super(channel);
this.getIndexRequest = getIndexRequest;
}
示例10: explain
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
@Override
public SqlElasticRequestBuilder explain() throws SqlParseException {
String sql = this.sql.replaceAll("\\s+"," ");
//todo: support indices with space?
String indexName = sql.split(" ")[1];
final GetIndexRequestBuilder indexRequestBuilder ;
String type = null;
if(indexName.contains("/")){
String[] indexAndType = indexName.split("\\/");
indexName = indexAndType[0];
type = indexAndType[1];
}
indexRequestBuilder = client.admin().indices().prepareGetIndex();
if(!indexName.equals("*")){
indexRequestBuilder.addIndices(indexName);
if(type!=null && !type.equals("")){
indexRequestBuilder.setTypes(type);
}
}
indexRequestBuilder.addFeatures(GetIndexRequest.Feature.MAPPINGS);
return new SqlElasticRequestBuilder() {
@Override
public ActionRequest request() {
return indexRequestBuilder.request();
}
@Override
public String explain() {
return indexRequestBuilder.toString();
}
@Override
public ActionResponse get() {
return indexRequestBuilder.get();
}
@Override
public ActionRequestBuilder getBuilder() {
return indexRequestBuilder;
}
};
}
示例11: initialSeedKibanaIndex
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
private boolean initialSeedKibanaIndex(final OpenshiftRequestContext context, Client esClient) {
try {
String userIndex = context.getKibanaIndex();
boolean kibanaIndexExists = pluginClient.indexExists(userIndex);
LOGGER.debug("Kibana index '{}' exists? {}", userIndex, kibanaIndexExists);
// copy the defaults if the userindex is not the kibanaindex
if (!kibanaIndexExists && !defaultKibanaIndex.equals(userIndex)) {
LOGGER.debug("Copying '{}' to '{}'", defaultKibanaIndex, userIndex);
GetIndexRequest getRequest = new GetIndexRequest().indices(defaultKibanaIndex);
getRequest.putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true");
GetIndexResponse getResponse = esClient.admin().indices().getIndex(getRequest).get();
CreateIndexRequest createRequest = new CreateIndexRequest().index(userIndex);
createRequest.putHeader(ConfigConstants.SG_CONF_REQUEST_HEADER, "true");
createRequest.settings(getResponse.settings().get(defaultKibanaIndex));
Map<String, Object> configMapping = getResponse.mappings().get(defaultKibanaIndex).get("config")
.getSourceAsMap();
createRequest.mapping("config", configMapping);
esClient.admin().indices().create(createRequest).actionGet();
// Wait for health status of YELLOW
ClusterHealthRequest healthRequest = new ClusterHealthRequest().indices(new String[] { userIndex })
.waitForYellowStatus();
esClient.admin().cluster().health(healthRequest).actionGet().getStatus();
return true;
}
} catch (ExecutionException | InterruptedException | IOException e) {
LOGGER.error("Unable to create initial Kibana index", e);
}
return false;
}
示例12: getMappings
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
public Set<Entry<String, Object>> getMappings(final String indexName, final Header... headers) throws IOException {
return performRequestAndParseEntity(new GetIndexRequest(), request -> getMappings(indexName), (
response) -> parseMappings(response, indexName), emptySet(), headers);
}
示例13: getIndex
import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
/**
* Get index metadata for particular indices.
*
* @param request The result future
*/
ActionFuture<GetIndexResponse> getIndex(GetIndexRequest request);