• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IndicesAliasesResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse的典型用法代码示例。如果您正苦于以下问题:Java IndicesAliasesResponse类的具体用法?Java IndicesAliasesResponse怎么用?Java IndicesAliasesResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndicesAliasesResponse类属于org.elasticsearch.action.admin.indices.alias包,在下文中一共展示了IndicesAliasesResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testSimpleCloseOpenAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
public void testSimpleCloseOpenAlias() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    IndicesAliasesResponse aliasesResponse = client.admin().indices().prepareAliases().addAlias("test1", "test1-alias").execute().actionGet();
    assertThat(aliasesResponse.isAcknowledged(), equalTo(true));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:OpenCloseIndexIT.java


示例2: testCloseOpenAliasMultipleIndices

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
public void testCloseOpenAliasMultipleIndices() {
    Client client = client();
    createIndex("test1", "test2");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));

    IndicesAliasesResponse aliasesResponse1 = client.admin().indices().prepareAliases().addAlias("test1", "test-alias").execute().actionGet();
    assertThat(aliasesResponse1.isAcknowledged(), equalTo(true));
    IndicesAliasesResponse aliasesResponse2 = client.admin().indices().prepareAliases().addAlias("test2", "test-alias").execute().actionGet();
    assertThat(aliasesResponse2.isAcknowledged(), equalTo(true));

    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");

    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:OpenCloseIndexIT.java


示例3: testAddAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void testAddAlias() {
    //Test data
    final String indexName = "index";
    final String aliasName = "alias";
    final AdminClient adminClient = createMock(AdminClient.class);
    final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
    final IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = createMock(IndicesAliasesRequestBuilder.class);
    final IndicesAliasesResponse indicesAliasesResponse = createMock(IndicesAliasesResponse.class);
    //Reset
    resetAll();
    //Expectations
    expect(esClient.admin()).andReturn(adminClient);
    expect(adminClient.indices()).andReturn(indicesAdminClient);
    expect(indicesAdminClient.prepareAliases()).andReturn(indicesAliasesRequestBuilder);
    expect(indicesAliasesRequestBuilder.addAlias(indexName, aliasName)).andReturn(indicesAliasesRequestBuilder);
    expect(indicesAliasesRequestBuilder.get()).andReturn(indicesAliasesResponse);
    //Replay
    replayAll();
    //Run test scenario
    final boolean result = elasticsearchClientWrapper.addAlias(indexName, aliasName);
    //Verify
    verifyAll();
    assertEquals(indicesAliasesResponse.isAcknowledged(), result);
}
 
开发者ID:Biacode,项目名称:escommons,代码行数:26,代码来源:ElasticsearchClientWrapperImplTest.java


示例4: alias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * Create an alias for a pattern
 * 
 * @param aliases
 *            a map of patterns to alias
 * @return true if the request was acknowledged
 */
public boolean alias(Map<String, String> aliases) {
    boolean acknowledged = false;
    if (aliases.isEmpty()) {
        LOGGER.trace("The alias map is empty.  Nothing to do");
        return acknowledged;
    }
    IndicesAliasesRequestBuilder builder = this.client.admin().indices().prepareAliases();
    addCommonHeaders(builder);
    for (Map.Entry<String, String> entry : aliases.entrySet()) {
        LOGGER.debug("Creating alias for {} as {}", entry.getKey(), entry.getValue());
        builder.addAlias(entry.getKey(), entry.getValue());
    }
    IndicesAliasesResponse response = builder.get();
    acknowledged = response.isAcknowledged();
    LOGGER.debug("Aliases request acknowledged? {}", acknowledged);
    return acknowledged;
}
 
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:25,代码来源:PluginClient.java


示例5: testExistsByAliasTrue

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void testExistsByAliasTrue () {
  //create index
  final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
  createIndexRequestBuilder.execute().actionGet();
  
  //create alias
  String alias = "test_alias";
  IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
  IndicesAliasesResponse response = builder.execute ().actionGet ();
  assertTrue(response.isAcknowledged ());
      
  //test exists
  IndexAdminHelper helper = new IndexAdminHelperImpl (client);
  assertTrue(helper.exists (alias));
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:17,代码来源:TestIndexAdminHelperImpl.java


示例6: testGetIndexAliases

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void testGetIndexAliases(){
  
  //Create index
  final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
  @SuppressWarnings ("unused")
  CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
  
  //Put the alias
  String alias = "test_alias";
  IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
  IndicesAliasesResponse response = builder.execute ().actionGet ();
  assertTrue(response.isAcknowledged ());
  
  IndexAdminHelper helper = new IndexAdminHelperImpl (client);    
  List<AliasMetaData> aliases = helper.getIndexAliases (indexName);
  
  if(log.isDebugEnabled ())
    for(AliasMetaData aliasMetaData : aliases)
      log.debug(String.format("***** Internal Index Name: %s", aliasMetaData.alias ()));
  
  assertEquals (1, aliases.size ());
  assertEquals (alias, aliases.get (0).alias ());
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:25,代码来源:TestIndexAdminHelperImpl.java


示例7: testGetIndexNameForAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void testGetIndexNameForAlias() throws IndexAdminException{
  
  //Create index
  final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
  @SuppressWarnings ("unused")
  CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
  
  //Put the alias
  String alias = "test_alias";
  IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ().addAlias (indexName, alias);
  IndicesAliasesResponse response = builder.execute ().actionGet ();
  assertTrue(response.isAcknowledged ());
  
  IndexAdminHelper helper = new IndexAdminHelperImpl (client);    
  String theIndexName = helper.getIndexNameForAlias(alias);
  log.debug(String.format("**** The index name: %s", theIndexName));
  assertEquals (indexName, theIndexName);
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:20,代码来源:TestIndexAdminHelperImpl.java


示例8: testPutIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void testPutIndexAlias(){
  
  //Create index
  final CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
  @SuppressWarnings ("unused")
  CreateIndexResponse createIndexResponse = createIndexRequestBuilder.execute().actionGet();
  
  //Put the alias
  String alias = "test_alias";
  IndexAdminHelper helper = new IndexAdminHelperImpl (client);
  IndicesAliasesResponse response = helper.putIndexAlias (indexName, alias);
  assertTrue(response.isAcknowledged ());
  
  GetAliasesRequestBuilder aliasesRequestBuilder = client.admin ().indices ().prepareGetAliases ();
  GetAliasesResponse getAliasesResponse = aliasesRequestBuilder.execute ().actionGet ();    
  List<AliasMetaData> aliases = getAliasesResponse.getAliases ().get (indexName);    
  
  if(log.isDebugEnabled ())
    for(AliasMetaData aliasMetaData : aliases)
      log.debug(String.format("***** Internal Index Name: %s", aliasMetaData.alias ()));
  
  assertEquals (1, aliases.size ());
  assertEquals (alias, aliases.get (0).alias ());
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:26,代码来源:TestIndexAdminHelperImpl.java


示例9: createAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * Create an alias if needed
 * @param alias
 * @param index
 * @throws Exception
 */
   private void createAlias(String alias, String index) throws Exception {
	if (logger.isTraceEnabled()){
		logger.trace("createAlias("+alias+","+index+")");
	}
	
	checkClient();
	
	IndicesAliasesResponse response = client.admin().indices().prepareAliases().addAlias(index, alias).execute().actionGet();
	if (!response.isAcknowledged()){
		throw new Exception("Could not define alias [" + alias + "] for index [" + index + "].");
	}
	if (logger.isTraceEnabled()){
		logger.trace("/createAlias("+alias+","+index+")");
	}
}
 
开发者ID:yamingd,项目名称:argo,代码行数:22,代码来源:ElasticsearchAbstractClientFactoryBean.java


示例10: handleRequest

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
    final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));
    IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
    indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
    indicesAliasesRequest.removeAlias(indices, aliases);
    indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));

    client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<IndicesAliasesResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:RestIndexDeleteAliasesAction.java


示例11: addIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * 给索引添加别名
 * 
 * @param index
 * @param alias
 * @return
 */
public boolean addIndexAlias(String index, String alias) {

    try {
        IndicesAliasesResponse resp = client.admin().indices().prepareAliases().addAlias(index, alias).get();

        return resp.isAcknowledged();
    }
    catch (Exception e) {
        return false;
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:19,代码来源:ESClient.java


示例12: removeIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * 给索引删除别名
 * 
 * @param index
 * @param alias
 * @return
 */
public boolean removeIndexAlias(String index, String alias) {

    try {
        IndicesAliasesResponse resp = client.admin().indices().prepareAliases().removeAlias(index, alias).get();
        return resp.isAcknowledged();
    }
    catch (Exception e) {
        return false;
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:18,代码来源:ESClient.java


示例13: execute

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * Creates a view (elasticsearch alias) with given name and query
 * @param sql
 * @param create
 * @param index
 * @return
 * @throws SQLException
 */
public int execute(String sql, CreateView create, String index) throws SQLException{
	
	String alias = create.getName().toString();
	alias = Heading.findOriginal(sql, alias, "\\s+view\\s+", "\\s+as\\s+");
	
	QueryBody queryBody = create.getQuery().getQueryBody();
	if(!(queryBody instanceof QuerySpecification)) throw new SQLException("Statement does not contain expected query specifiction");
	QuerySpecification querySpec = (QuerySpecification)queryBody;
	if(!querySpec.getFrom().isPresent()) throw new SQLException("Add atleast one INDEX to the query to create the view from");
	
	QueryState state = new BasicQueryState(sql, new Heading(), props);
	List<QuerySource> relations = new RelationParser().process(querySpec.getFrom().get(), null);
	String[] indices = new String[relations.size()];
	for(int i=0; i<relations.size(); i++) indices[i] = relations.get(i).getSource();
	new SelectParser().process(querySpec.getSelect(), state);
	
	IndicesAliasesResponse response;
	if(querySpec.getWhere().isPresent()){
		QueryBuilder query = new WhereParser().process(querySpec.getWhere().get(), state).getQuery();
		response = client.admin().indices().prepareAliases().addAlias(indices, alias, query).execute().actionGet();
	}else{
		response = client.admin().indices().prepareAliases().addAlias(indices, alias).execute().actionGet();
	}
	if(!response.isAcknowledged()) throw new SQLException("Elasticsearch failed to create the specified alias");
	this.statement.getConnection().getTypeMap(); // trigger a reload of the table&column set for the connection
	return 0; // the number of altered rows
}
 
开发者ID:Anchormen,项目名称:sql4es,代码行数:36,代码来源:ESUpdateState.java


示例14: createIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Override
public void createIndexAlias(String indexName, String aliasName) {
    IndicesAliasesResponse response = indicesAdminClient().prepareAliases().addAlias(indexName, aliasName).execute()
        .actionGet();

    log.info("Index: " + indexName + ", isAcknowledged: " + response.isAcknowledged());
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:8,代码来源:DefaultElasticsearchIndexHelper.java


示例15: removeIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Override
public void removeIndexAlias(String indexName, String aliasName) {
    IndicesAliasesResponse response = indicesAdminClient().prepareAliases().removeAlias(indexName, aliasName)
        .execute().actionGet();

    log.info("Index: " + indexName + ", isAcknowledged: " + response.isAcknowledged());
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:8,代码来源:DefaultElasticsearchIndexHelper.java


示例16: activateIndex

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * Activates an index by moving the alias from the old index to the new one.
 */
@Override
public void activateIndex(String indexName, String aliasName) {
    Map<String, Set<String>> indexAliasMap = getIndexAliases();

    IndicesAliasesRequestBuilder builder = indicesAdminClient().prepareAliases();

    if (indexAliasMap.size() > 0) {
        Set<String> aliasNames = indexAliasMap.keySet();

        for (String an : aliasNames) {
            Set<String> indexNames = indexAliasMap.get(an);

            for (String in : indexNames) {
                if (an.equals(aliasName)) {
                    log.info("Removing alias '" + an + "' from index '" + in + "'.");

                    builder.removeAlias(in, an);
                }
            }
        }
    }

    IndicesAliasesResponse response = builder.addAlias(indexName, aliasName).execute().actionGet();

    log.info("activateIndex: [indexName=" + indexName + ", aliasName=" + aliasName + ", isAcknowledged="
        + response.isAcknowledged() + "].");
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:31,代码来源:DefaultElasticsearchIndexHelper.java


示例17: createAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
/**
 * Create an alias if needed
 * @param alias Alias name
 * @param index Index name
 * @throws Exception When alias can not be set
 */
@Deprecated
public static void createAlias(Client client, String alias, String index) throws Exception {
    logger.trace("createAlias({},{})", alias, index);
    IndicesAliasesResponse response = client.admin().indices().prepareAliases().addAlias(index, alias).get();
    if (!response.isAcknowledged()) throw new Exception("Could not define alias [" + alias + "] for index [" + index + "].");
    logger.trace("/createAlias({},{})", alias, index);
}
 
开发者ID:dadoonet,项目名称:elasticsearch-beyonder,代码行数:14,代码来源:AliasElasticsearchUpdater.java


示例18: reorder

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Test
public void reorder() throws Exception {

    assertThat(1, is(runner.getNodeSize()));
    final Client client = runner.client();

    final String index = "sample";
    final String alias = "test";
    final String type = "data";
    CreateIndexResponse createIndexResponse = runner.createIndex(index,
            Settings.builder().put(DynamicRanker.SETTING_INDEX_DYNARANK_REORDER_SIZE.getKey(), 100)
                    .put(DynamicRanker.SETTING_INDEX_DYNARANK_LANG.getKey(), "groovy")
                    .put(DynamicRanker.SETTING_INDEX_DYNARANK_SCRIPT.getKey(),
                            "searchHits.sort {s1, s2 -> s2.getSource().get('counter') - s1.getSource().get('counter')} as org.elasticsearch.search.SearchHit[]")
                    .put(DynamicRanker.SETTING_INDEX_DYNARANK_PARAMS.getKey() + "foo", "bar").build());
    assertTrue(createIndexResponse.isAcknowledged());
    IndicesAliasesResponse aliasesResponse = runner.updateAlias(alias, new String[] { index }, null);
    assertTrue(aliasesResponse.isAcknowledged());

    for (int i = 1; i <= 1000; i++) {
        final IndexResponse indexResponse1 = runner.insert(index, type, String.valueOf(i),
                "{\"id\":\"" + i + "\",\"msg\":\"test " + i + "\",\"counter\":" + i + "}");
        assertEquals(Result.CREATED, indexResponse1.getResult());
    }

    assertResultOrder(client, index, type);
    assertResultOrder(client, alias, type);

    String index2 = index + "2";
    runner.createIndex(index2, (Settings) null);
    runner.updateAlias(alias, new String[] { index2 }, null);
    int tempId = 99999;
    runner.insert(index2, type, String.valueOf(tempId),
            "{\"id\":\"" + tempId + "\",\"msg\":\"test " + tempId + "\",\"counter\":" + tempId + "}");
    runner.delete(index2, type, String.valueOf(tempId));
    runner.refresh();
    assertResultOrder(client, alias, type);
}
 
开发者ID:codelibs,项目名称:elasticsearch-dynarank,代码行数:39,代码来源:DynamicRankingPluginTest.java


示例19: updateAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
public IndicesAliasesResponse updateAlias(final String alias,
        final String[] addedIndices, final String[] deletedIndices) {
    return updateAlias(builder -> {
        if (addedIndices != null && addedIndices.length > 0) {
    builder.addAlias(addedIndices, alias);
        }
        if (deletedIndices != null && deletedIndices.length > 0) {
    builder.removeAlias(deletedIndices, alias);
        }
        return builder;
     });
}
 
开发者ID:codelibs,项目名称:elasticsearch-cluster-runner,代码行数:13,代码来源:ElasticsearchClusterRunner.java


示例20: redirectIndexAlias

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; //导入依赖的package包/类
@Override
public IndicesAliasesResponse redirectIndexAlias(String alias, String oldIndexName, String newIndexName){
  IndicesAliasesRequestBuilder builder = client.admin().indices ().prepareAliases ()
          .removeAlias (oldIndexName, alias)
          .addAlias (newIndexName, alias);    
  IndicesAliasesResponse response = builder.execute ().actionGet ();
  return response;
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:9,代码来源:IndexAdminHelperImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestContextManager类代码示例发布时间:2022-05-21
下一篇:
Java AsyncService类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap