本文整理汇总了Java中org.elasticsearch.cluster.metadata.AliasOrIndex类的典型用法代码示例。如果您正苦于以下问题:Java AliasOrIndex类的具体用法?Java AliasOrIndex怎么用?Java AliasOrIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AliasOrIndex类属于org.elasticsearch.cluster.metadata包,在下文中一共展示了AliasOrIndex类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getIndexMetaData
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
private IndexMetaData getIndexMetaData(String indexName) {
AliasOrIndex aliasOrIndex = elasticsearchTemplate.getClient()
.admin()
.cluster()
.state(Requests.clusterStateRequest())
.actionGet()
.getState()
.getMetaData()
.getAliasAndIndexLookup()
.get(indexName);
if (aliasOrIndex == null) {
return null;
}
return aliasOrIndex.getIndices().get(0);
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:17,代码来源:ElasticsearchEdmProviderResolver.java
示例2: getSchemas
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
@Override
public ResultSet getSchemas() throws SQLException {
ImmutableOpenMap<String, IndexMetaData> indices = client.admin().cluster()
.prepareState().get().getState()
.getMetaData().getIndices();
SortedMap<String, AliasOrIndex> aliasAndIndices = client.admin().cluster().prepareState().get().getState()
.getMetaData().getAliasAndIndexLookup();
Heading heading = new Heading();
heading.add(new Column("TABLE_SCHEM"));
heading.add(new Column("TABLE_CATALOG"));
ESResultSet result = new ESResultSet(heading, indices.size(), heading.getColumnCount());
for(String key : aliasAndIndices.keySet()){
List<Object> row = result.getNewRow();
row.set(0, key);
row.set(1, aliasAndIndices.get(key).isAlias() ? "alias" : "index");
result.add(row);
}
return result;
}
开发者ID:Anchormen,项目名称:sql4es,代码行数:22,代码来源:ESDatabaseMetaData.java
示例3: getAnalyzer
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
private Analyzer getAnalyzer(final String indexName, final String analyzerName) throws IOException {
final MetaData metaData = pluginComponent.getAnalyzeApiService().getClusterService().state().getMetaData();
final AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(indexName);
if (aliasOrIndex != null) {
for (final IndexMetaData indexMD : aliasOrIndex.getIndices()) {
final IndexService indexService =
pluginComponent.getAnalyzeApiService().getIndicesService().indexService(indexMD.getIndex());
if (indexService != null) {
final Analyzer analyzer = indexService.getIndexAnalyzers().get(analyzerName);
if (analyzer != null) {
return analyzer;
}
}
}
}
return pluginComponent.getAnalyzeApiService().getAnalysisRegistry().getAnalyzer(analyzerName);
}
开发者ID:codelibs,项目名称:elasticsearch-analyze-api,代码行数:18,代码来源:RestAnalyzeApiAction.java
示例4: validate
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
static void validate(MetaData metaData, RolloverRequest request) {
final AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(request.getAlias());
if (aliasOrIndex == null) {
throw new IllegalArgumentException("source alias does not exist");
}
if (aliasOrIndex.isAlias() == false) {
throw new IllegalArgumentException("source alias is a concrete index");
}
if (aliasOrIndex.getIndices().size() != 1) {
throw new IllegalArgumentException("source alias maps to multiple indices");
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:TransportRolloverAction.java
示例5: testSameAlias
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
public void testSameAlias() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "name", "type=text"));
ensureGreen();
logger.info("--> creating alias1 ");
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1")));
TimeValue timeout = TimeValue.timeValueSeconds(2);
logger.info("--> recreating alias1 ");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> modifying alias1 to have a filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with the same filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with a different filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "bar")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> verify that filter was updated");
AliasMetaData aliasMetaData = ((AliasOrIndex.Alias) internalCluster().clusterService().state().metaData().getAliasAndIndexLookup().get("alias1")).getFirstAliasMetaData();
assertThat(aliasMetaData.getFilter().toString(), equalTo("{\"term\":{\"name\":{\"value\":\"bar\",\"boost\":1.0}}}"));
logger.info("--> deleting alias1");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:IndexAliasesIT.java
示例6: deleteAllIndexesInES
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
protected void deleteAllIndexesInES() {
SortedMap<String, AliasOrIndex> aliasAndIndexLookup = node.client().admin().cluster()
.prepareState().execute().actionGet().getState().getMetaData().getAliasAndIndexLookup();
for (String alias: aliasAndIndexLookup.keySet()) {
node.client().admin().indices().prepareDelete(alias).execute().actionGet();
}
node.client().admin().indices().prepareRefresh().execute().actionGet();
}
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:9,代码来源:BaseIntegrationTest.java
示例7: getScriptInfo
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
public ScriptInfo getScriptInfo(final String index) {
try {
return scriptInfoCache.get(index, () -> {
final MetaData metaData = clusterService.state().getMetaData();
final AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(index);
if (aliasOrIndex == null) {
return ScriptInfo.NO_SCRIPT_INFO;
}
final ScriptInfo[] scriptInfos = aliasOrIndex.getIndices().stream().map(md -> md.getSettings())
.filter(s -> SETTING_INDEX_DYNARANK_LANG.get(s).length() > 0)
.map(settings -> new ScriptInfo(SETTING_INDEX_DYNARANK_SCRIPT.get(settings),
SETTING_INDEX_DYNARANK_LANG.get(settings), SETTING_INDEX_DYNARANK_TYPE.get(settings),
SETTING_INDEX_DYNARANK_PARAMS.get(settings), SETTING_INDEX_DYNARANK_REORDER_SIZE.get(settings)))
.toArray(n -> new ScriptInfo[n]);
if (scriptInfos.length == 0) {
return ScriptInfo.NO_SCRIPT_INFO;
} else if (scriptInfos.length == 1) {
return scriptInfos[0];
} else {
for (final ScriptInfo scriptInfo : scriptInfos) {
if (!scriptInfo.getLang().equals(DiversitySortScriptEngineService.SCRIPT_NAME)) {
return ScriptInfo.NO_SCRIPT_INFO;
}
}
return scriptInfos[0];
}
});
} catch (final Exception e) {
logger.warn("Failed to load ScriptInfo for {}.", e, index);
return null;
}
}
开发者ID:codelibs,项目名称:elasticsearch-dynarank,代码行数:35,代码来源:DynamicRanker.java
示例8: masterOperation
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
@Override
protected void masterOperation(final RolloverRequest rolloverRequest, final ClusterState state,
final ActionListener<RolloverResponse> listener) {
final MetaData metaData = state.metaData();
validate(metaData, rolloverRequest);
final AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(rolloverRequest.getAlias());
final IndexMetaData indexMetaData = aliasOrIndex.getIndices().get(0);
final String sourceProvidedName = indexMetaData.getSettings().get(IndexMetaData.SETTING_INDEX_PROVIDED_NAME,
indexMetaData.getIndex().getName());
final String sourceIndexName = indexMetaData.getIndex().getName();
final String unresolvedName = (rolloverRequest.getNewIndexName() != null)
? rolloverRequest.getNewIndexName()
: generateRolloverIndexName(sourceProvidedName, indexNameExpressionResolver);
final String rolloverIndexName = indexNameExpressionResolver.resolveDateMathExpression(unresolvedName);
MetaDataCreateIndexService.validateIndexName(rolloverIndexName, state); // will fail if the index already exists
client.admin().indices().prepareStats(sourceIndexName).clear().setDocs(true).execute(
new ActionListener<IndicesStatsResponse>() {
@Override
public void onResponse(IndicesStatsResponse statsResponse) {
final Set<Condition.Result> conditionResults = evaluateConditions(rolloverRequest.getConditions(),
statsResponse.getTotal().getDocs(), metaData.index(sourceIndexName));
if (rolloverRequest.isDryRun()) {
listener.onResponse(
new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults, true, false, false, false));
return;
}
if (conditionResults.size() == 0 || conditionResults.stream().anyMatch(result -> result.matched)) {
CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(unresolvedName, rolloverIndexName,
rolloverRequest);
createIndexService.createIndex(updateRequest, ActionListener.wrap(createIndexClusterStateUpdateResponse -> {
// switch the alias to point to the newly created index
indexAliasesService.indicesAliases(
prepareRolloverAliasesUpdateRequest(sourceIndexName, rolloverIndexName,
rolloverRequest),
ActionListener.wrap(aliasClusterStateUpdateResponse -> {
if (aliasClusterStateUpdateResponse.isAcknowledged()) {
activeShardsObserver.waitForActiveShards(rolloverIndexName,
rolloverRequest.getCreateIndexRequest().waitForActiveShards(),
rolloverRequest.masterNodeTimeout(),
isShardsAcked -> listener.onResponse(new RolloverResponse(sourceIndexName, rolloverIndexName,
conditionResults, false, true, true, isShardsAcked)),
listener::onFailure);
} else {
listener.onResponse(new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults,
false, true, false, false));
}
}, listener::onFailure));
}, listener::onFailure));
} else {
// conditions not met
listener.onResponse(
new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults, false, false, false, false)
);
}
}
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
}
);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:65,代码来源:TransportRolloverAction.java
示例9: getOnlyAliases
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
protected List<String> getOnlyAliases(final List<String> indices) {
final List<String> result = new ArrayList<String>();
final SortedMap<String, AliasOrIndex> aliases = clusterService.state().metaData().getAliasAndIndexLookup();
for (int i = 0; i < indices.size(); i++) {
final String index = indices.get(i);
final AliasOrIndex indexAliases = aliases.get(index);
if (indexAliases.isAlias()) {
result.add(index);
}
}
return result;
}
开发者ID:petalmd,项目名称:armor,代码行数:20,代码来源:AbstractActionFilter.java
示例10: getOnlyAliases
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
private List<String> getOnlyAliases(final List<String> indices) {
final List<String> result = new ArrayList<String>();
final SortedMap<String, AliasOrIndex> aliases = clusterService.state().metaData().getAliasAndIndexLookup();
for (int i = 0; i < indices.size(); i++) {
final String index = indices.get(i);
final AliasOrIndex indexAliases = aliases.get(index);
if (indexAliases.isAlias()) {
result.add(index);
}
}
return result;
}
开发者ID:petalmd,项目名称:armor,代码行数:20,代码来源:ArmorActionFilter.java
示例11: resolveAliases
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
protected List<String> resolveAliases(final List<String> indices) {
final List<String> result = new ArrayList<String>();
final SortedMap<String, AliasOrIndex> aliases = clusterService.state().metaData().getAliasAndIndexLookup();
for (int i = 0; i < indices.size(); i++) {
final String index = indices.get(i);
final AliasOrIndex indexAliases = aliases.get(index);
if (!indexAliases.isAlias()) {
result.add(index);
log.trace("{} is an concrete index", index);
continue;
}
log.trace("{} is an alias and points to -> {}", index, indexAliases.getIndices());
final Iterable<Tuple<String, AliasMetaData>> iterable = ((AliasOrIndex.Alias) indexAliases).getConcreteIndexAndAliasMetaDatas();
for (final Iterator<Tuple<String, AliasMetaData>> iterator = iterable.iterator(); iterator.hasNext();) {
final Tuple<String, AliasMetaData> entry = iterator.next();
result.add(entry.v1());
}
}
return result;
}
开发者ID:petalmd,项目名称:armor,代码行数:32,代码来源:AbstractActionFilter.java
示例12: resolveAliases
import org.elasticsearch.cluster.metadata.AliasOrIndex; //导入依赖的package包/类
private List<String> resolveAliases(final List<String> indices) {
final List<String> result = new ArrayList<String>();
final SortedMap<String, AliasOrIndex> aliases = clusterService.state().metaData().getAliasAndIndexLookup();
for (int i = 0; i < indices.size(); i++) {
final String index = indices.get(i);
final AliasOrIndex indexAliases = aliases.get(index);
if (!indexAliases.isAlias()) {
result.add(index);
log.trace("{} is an concrete index", index);
continue;
}
log.trace("{} is an alias and points to -> {}", index, indexAliases.getIndices());
final Iterable<Tuple<String, AliasMetaData>> iterable = ((AliasOrIndex.Alias) indexAliases).getConcreteIndexAndAliasMetaDatas();
for (final Iterator<Tuple<String, AliasMetaData>> iterator = iterable.iterator(); iterator.hasNext();) {
final Tuple<String, AliasMetaData> entry = iterator.next();
result.add(entry.v1());
}
}
return result;
}
开发者ID:petalmd,项目名称:armor,代码行数:32,代码来源:ArmorActionFilter.java
注:本文中的org.elasticsearch.cluster.metadata.AliasOrIndex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论