Java Code Examples for org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse#isAcknowledged()
The following examples show how to use
org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse#isAcknowledged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ESClient.java From uavstack with Apache License 2.0 | 5 votes |
/** * 给索引添加别名 * * @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; } }
Example 2
Source File: ESClient.java From uavstack with Apache License 2.0 | 5 votes |
/** * 给索引删除别名 * * @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; } }
Example 3
Source File: ESUpdateState.java From sql4es with Apache License 2.0 | 5 votes |
/** * 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 }