当前位置: 首页>>代码示例>>Java>>正文


Java GetIndexRequest类代码示例

本文整理汇总了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;
  }
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:17,代码来源:ESDriver.java

示例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()));
	}
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:25,代码来源:ActionRequestRestExecuter.java

示例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;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:Elasticsearch2Schema.java

示例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;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:Elasticsearch5Schema.java

示例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());
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:27,代码来源:FilterActionTest.java

示例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);
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:31,代码来源:GetIndexRequestRestListener.java

示例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;
}
 
开发者ID:Yirendai,项目名称:cicada,代码行数:14,代码来源:ElasticIndexManager.java

示例8: getIndex

import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
@Override
public ActionFuture<GetIndexResponse> getIndex(GetIndexRequest request) {
    return execute(GetIndexAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例9: GetIndexRequestRestListener

import org.elasticsearch.action.admin.indices.get.GetIndexRequest; //导入依赖的package包/类
public GetIndexRequestRestListener(RestChannel channel,GetIndexRequest getIndexRequest) {
    super(channel);
    this.getIndexRequest = getIndexRequest;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:5,代码来源:GetIndexRequestRestListener.java

示例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;
        }
    };
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:45,代码来源:ShowQueryAction.java

示例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;
    }
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:42,代码来源:KibanaSeed.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:5,代码来源:ElasticSearchRestClient.java

示例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);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:IndicesAdminClient.java


注:本文中的org.elasticsearch.action.admin.indices.get.GetIndexRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。