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


Java Index类代码示例

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


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

示例1: masterOperation

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Override
protected void masterOperation(final DeleteIndexRequest request, final ClusterState state, final ActionListener<DeleteIndexResponse> listener) {
    final Set<Index> concreteIndices = new HashSet<>(Arrays.asList(indexNameExpressionResolver.concreteIndices(state, request)));
    if (concreteIndices.isEmpty()) {
        listener.onResponse(new DeleteIndexResponse(true));
        return;
    }

    DeleteIndexClusterStateUpdateRequest deleteRequest = new DeleteIndexClusterStateUpdateRequest()
        .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
        .indices(concreteIndices.toArray(new Index[concreteIndices.size()]));

    deleteIndexService.deleteIndices(deleteRequest, new ActionListener<ClusterStateUpdateResponse>() {

        @Override
        public void onResponse(ClusterStateUpdateResponse response) {
            listener.onResponse(new DeleteIndexResponse(response.isAcknowledged()));
        }

        @Override
        public void onFailure(Exception t) {
            logger.debug((Supplier<?>) () -> new ParameterizedMessage("failed to delete indices [{}]", concreteIndices), t);
            listener.onFailure(t);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:TransportDeleteIndexAction.java

示例2: routingKeyForShard

import org.elasticsearch.index.Index; //导入依赖的package包/类
synchronized String routingKeyForShard(Index index, int shard, Random random) {
    assertThat(shard, greaterThanOrEqualTo(0));
    assertThat(shard, greaterThanOrEqualTo(0));
    for (NodeAndClient n : nodes.values()) {
        Node node = n.node;
        IndicesService indicesService = getInstanceFromNode(IndicesService.class, node);
        ClusterService clusterService = getInstanceFromNode(ClusterService.class, node);
        IndexService indexService = indicesService.indexService(index);
        if (indexService != null) {
            assertThat(indexService.getIndexSettings().getSettings().getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, -1), greaterThan(shard));
            OperationRouting operationRouting = clusterService.operationRouting();
            while (true) {
                String routing = RandomStrings.randomAsciiOfLength(random, 10);
                final int targetShard = operationRouting.indexShards(clusterService.state(), index.getName(), null, routing).shardId().getId();
                if (shard == targetShard) {
                    return routing;
                }
            }
        }
    }
    fail("Could not find a node that holds " + index);
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:InternalTestCluster.java

示例3: HunspellTokenFilterFactory

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Inject
public HunspellTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings, HunspellService hunspellService)  {
    super(index, indexSettingsService.getSettings(), name, settings);

    String locale = settings.get("locale", settings.get("language", settings.get("lang", null)));
    if (locale == null) {
        throw new IllegalArgumentException("missing [locale | language | lang] configuration for hunspell token filter");
    }

    dictionary = hunspellService.getDictionary(locale);
    if (dictionary == null) {
        throw new IllegalArgumentException(String.format(Locale.ROOT, "Unknown hunspell dictionary for locale [%s]", locale));
    }

    dedup = settings.getAsBoolean("dedup", true);
    longestOnly = settings.getAsBoolean("longest_only", false);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:HunspellTokenFilterFactory.java

示例4: createStatsByIndex

import org.elasticsearch.index.Index; //导入依赖的package包/类
private Map<Index, CommonStats> createStatsByIndex() {
    Map<Index, CommonStats> statsMap = new HashMap<>();
    for (Map.Entry<Index, List<IndexShardStats>> entry : statsByShard.entrySet()) {
        if (!statsMap.containsKey(entry.getKey())) {
            statsMap.put(entry.getKey(), new CommonStats());
        }

        for (IndexShardStats indexShardStats : entry.getValue()) {
            for (ShardStats shardStats : indexShardStats.getShards()) {
                statsMap.get(entry.getKey()).add(shardStats.getStats());
            }
        }
    }

    return statsMap;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:NodeIndicesStats.java

示例5: upgradeMultiDataPath

import org.elasticsearch.index.Index; //导入依赖的package包/类
/**
 * Runs an upgrade on all shards located under the given node environment if there is more than 1 data.path configured
 * otherwise this method will return immediately.
 */
public static void upgradeMultiDataPath(NodeEnvironment nodeEnv, ESLogger logger) throws IOException {
    if (nodeEnv.nodeDataPaths().length > 1) {
        final MultiDataPathUpgrader upgrader = new MultiDataPathUpgrader(nodeEnv);
        final Set<String> allIndices = nodeEnv.findAllIndices();

        for (String index : allIndices) {
            for (ShardId shardId : findAllShardIds(nodeEnv.indexPaths(new Index(index)))) {
                try (ShardLock lock = nodeEnv.shardLock(shardId, 0)) {
                    if (upgrader.needsUpgrading(shardId)) {
                        final ShardPath shardPath = upgrader.pickShardPath(shardId);
                        upgrader.upgrade(shardId, shardPath);
                        // we have to check if the index path exists since we might
                        // have only upgraded the shard state that is written under /indexname/shardid/_state
                        // in the case we upgraded a dedicated index directory index
                        if (Files.exists(shardPath.resolveIndex())) {
                            upgrader.checkIndex(shardPath);
                        }
                    } else {
                        logger.debug("{} no upgrade needed - already upgraded", shardId);
                    }
                }
            }
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:30,代码来源:MultiDataPathUpgrader.java

示例6: PathHierarchyTokenizerFactory

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Inject
public PathHierarchyTokenizerFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    bufferSize = settings.getAsInt("buffer_size", 1024);
    String delimiter = settings.get("delimiter");
    if (delimiter == null) {
        this.delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
    } else if (delimiter.length() > 1) {
        throw new IllegalArgumentException("delimiter can only be a one char value");
    } else {
        this.delimiter = delimiter.charAt(0);
    }

    String replacement = settings.get("replacement");
    if (replacement == null) {
        this.replacement = this.delimiter;
    } else if (replacement.length() > 1) {
        throw new IllegalArgumentException("replacement can only be a one char value");
    } else {
        this.replacement = replacement.charAt(0);
    }
    this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP);
    this.reverse = settings.getAsBoolean("reverse", false);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:PathHierarchyTokenizerFactory.java

示例7: getExpectedShardSize

import org.elasticsearch.index.Index; //导入依赖的package包/类
/**
 * Returns the expected shard size for the given shard or the default value provided if not enough information are available
 * to estimate the shards size.
 */
public static long getExpectedShardSize(ShardRouting shard, RoutingAllocation allocation, long defaultValue) {
    final IndexMetaData metaData = allocation.metaData().getIndexSafe(shard.index());
    final ClusterInfo info = allocation.clusterInfo();
    if (metaData.getMergeSourceIndex() != null && shard.active() == false &&
        shard.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) {
        // in the shrink index case we sum up the source index shards since we basically make a copy of the shard in
        // the worst case
        long targetShardSize = 0;
        final Index mergeSourceIndex = metaData.getMergeSourceIndex();
        final IndexMetaData sourceIndexMeta = allocation.metaData().getIndexSafe(mergeSourceIndex);
        final Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(shard.id(), sourceIndexMeta, metaData.getNumberOfShards());
        for (IndexShardRoutingTable shardRoutingTable : allocation.routingTable().index(mergeSourceIndex.getName())) {
            if (shardIds.contains(shardRoutingTable.shardId())) {
                targetShardSize += info.getShardSize(shardRoutingTable.primaryShard(), 0);
            }
        }
        return targetShardSize == 0 ? defaultValue : targetShardSize;
    } else {
        return info.getShardSize(shard, defaultValue);
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:DiskThresholdDecider.java

示例8: masterOperation

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Override
protected void masterOperation(final OpenIndexRequest request, final ClusterState state, final ActionListener<OpenIndexResponse> listener) {
    final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request);
    OpenIndexClusterStateUpdateRequest updateRequest = new OpenIndexClusterStateUpdateRequest()
            .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout())
            .indices(concreteIndices);

    indexStateService.openIndex(updateRequest, new ActionListener<ClusterStateUpdateResponse>() {

        @Override
        public void onResponse(ClusterStateUpdateResponse response) {
            listener.onResponse(new OpenIndexResponse(response.isAcknowledged()));
        }

        @Override
        public void onFailure(Exception t) {
            logger.debug((Supplier<?>) () -> new ParameterizedMessage("failed to open indices [{}]", (Object) concreteIndices), t);
            listener.onFailure(t);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:TransportOpenIndexAction.java

示例9: randomClusterAllocationExplanation

import org.elasticsearch.index.Index; //导入依赖的package包/类
private static ClusterAllocationExplanation randomClusterAllocationExplanation(boolean assignedShard) {
    ShardRouting shardRouting = TestShardRouting.newShardRouting(new ShardId(new Index("idx", "123"), 0),
        assignedShard ? "node-0" : null, true, assignedShard ? ShardRoutingState.STARTED : ShardRoutingState.UNASSIGNED);
    DiscoveryNode node = assignedShard ? new DiscoveryNode("node-0", buildNewFakeTransportAddress(), emptyMap(), emptySet(),
                                                              Version.CURRENT) : null;
    ShardAllocationDecision shardAllocationDecision;
    if (assignedShard) {
        MoveDecision moveDecision = MoveDecision.cannotRebalance(Decision.YES, AllocationDecision.NO, 3, null)
                                        .withRemainDecision(Decision.YES);
        shardAllocationDecision = new ShardAllocationDecision(AllocateUnassignedDecision.NOT_TAKEN, moveDecision);
    } else {
        AllocateUnassignedDecision allocateDecision = AllocateUnassignedDecision.no(UnassignedInfo.AllocationStatus.DECIDERS_NO, null);
        shardAllocationDecision = new ShardAllocationDecision(allocateDecision, MoveDecision.NOT_TAKEN);
    }
    return new ClusterAllocationExplanation(shardRouting, node, null, null, shardAllocationDecision);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:ClusterAllocationExplanationTests.java

示例10: lockAllForIndex

import org.elasticsearch.index.Index; //导入依赖的package包/类
/**
 * Tries to lock all local shards for the given index. If any of the shard locks can't be acquired
 * a {@link ShardLockObtainFailedException} is thrown and all previously acquired locks are released.
 *
 * @param index the index to lock shards for
 * @param lockTimeoutMS how long to wait for acquiring the indices shard locks
 * @return the {@link ShardLock} instances for this index.
 * @throws IOException if an IOException occurs.
 */
public List<ShardLock> lockAllForIndex(Index index, IndexSettings settings, long lockTimeoutMS)
        throws IOException, ShardLockObtainFailedException {
    final int numShards = settings.getNumberOfShards();
    if (numShards <= 0) {
        throw new IllegalArgumentException("settings must contain a non-null > 0 number of shards");
    }
    logger.trace("locking all shards for index {} - [{}]", index, numShards);
    List<ShardLock> allLocks = new ArrayList<>(numShards);
    boolean success = false;
    long startTimeNS = System.nanoTime();
    try {
        for (int i = 0; i < numShards; i++) {
            long timeoutLeftMS = Math.max(0, lockTimeoutMS - TimeValue.nsecToMSec((System.nanoTime() - startTimeNS)));
            allLocks.add(shardLock(new ShardId(index, i), timeoutLeftMS));
        }
        success = true;
    } finally {
        if (success == false) {
            logger.trace("unable to lock all shards for index {}", index);
            IOUtils.closeWhileHandlingException(allLocks);
        }
    }
    return allLocks;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:NodeEnvironment.java

示例11: testDefaultsIcuAnalysis

import org.elasticsearch.index.Index; //导入依赖的package包/类
public void testDefaultsIcuAnalysis() throws IOException {
    TestAnalysis analysis = createTestAnalysis(new Index("test", "_na_"), Settings.EMPTY, new AnalysisICUPlugin());

    TokenizerFactory tokenizerFactory = analysis.tokenizer.get("icu_tokenizer");
    assertThat(tokenizerFactory, instanceOf(IcuTokenizerFactory.class));

    TokenFilterFactory filterFactory = analysis.tokenFilter.get("icu_normalizer");
    assertThat(filterFactory, instanceOf(IcuNormalizerTokenFilterFactory.class));

    filterFactory = analysis.tokenFilter.get("icu_folding");
    assertThat(filterFactory, instanceOf(IcuFoldingTokenFilterFactory.class));

    filterFactory = analysis.tokenFilter.get("icu_collation");
    assertThat(filterFactory, instanceOf(IcuCollationTokenFilterFactory.class));

    filterFactory = analysis.tokenFilter.get("icu_transform");
    assertThat(filterFactory, instanceOf(IcuTransformTokenFilterFactory.class));

    CharFilterFactory charFilterFactory = analysis.charFilter.get("icu_normalizer");
    assertThat(charFilterFactory, instanceOf(IcuNormalizerCharFilterFactory.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SimpleIcuAnalysisTests.java

示例12: IndexStore

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Inject
public IndexStore(Index index, IndexSettingsService settingsService, IndicesStore indicesStore) {
    super(index, settingsService.getSettings());
    Settings indexSettings = settingsService.getSettings();
    this.indicesStore = indicesStore;

    this.rateLimitingType = indexSettings.get(INDEX_STORE_THROTTLE_TYPE, "none");
    if (rateLimitingType.equalsIgnoreCase("node")) {
        nodeRateLimiting = true;
    } else {
        nodeRateLimiting = false;
        rateLimiting.setType(rateLimitingType);
    }
    this.rateLimitingThrottle = indexSettings.getAsBytesSize(INDEX_STORE_THROTTLE_MAX_BYTES_PER_SEC, new ByteSizeValue(0));
    rateLimiting.setMaxRate(rateLimitingThrottle);

    logger.debug("using index.store.throttle.type [{}], with index.store.throttle.max_bytes_per_sec [{}]", rateLimitingType, rateLimitingThrottle);
    this.settingsService = settingsService;
    this.settingsService.addListener(applySettings);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:IndexStore.java

示例13: HungarianAnalyzerProvider

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Inject
public HungarianAnalyzerProvider(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    analyzer = new HungarianAnalyzer(Analysis.parseStopWords(env, settings, HungarianAnalyzer.getDefaultStopSet()),
                                     Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET));
    analyzer.setVersion(version);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:HungarianAnalyzerProvider.java

示例14: testDefaultsRSLPAnalysis

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Test
public void testDefaultsRSLPAnalysis() throws IOException {
    AnalysisService analysisService = createAnalysisService(new Index("test", "_na_"), Settings.EMPTY, new AnalysisMetaphonePlugin());

    TokenFilterFactory tokenizerFactory = analysisService.tokenFilter("br_metaphone");

    MatcherAssert.assertThat(tokenizerFactory, instanceOf(MetaphoneTokenFilterFactory.class));
}
 
开发者ID:anaelcarvalho,项目名称:elasticsearch-analysis-metaphone_ptBR,代码行数:9,代码来源:MetaphoneAnalysisTests.java

示例15: testMetaphoneWords

import org.elasticsearch.index.Index; //导入依赖的package包/类
@Test
public void testMetaphoneWords() throws Exception {
    Index index = new Index("test", "_na_");
    Settings settings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("index.analysis.filter.myStemmer.type", "br_metaphone")
            .build();

    AnalysisService analysisService = createAnalysisService(index, settings, new AnalysisMetaphonePlugin());

    TokenFilterFactory filterFactory = analysisService.tokenFilter("br_metaphone");

    Tokenizer tokenizer = new KeywordTokenizer();
    
    Map<String,String> words = buildWordList();
    
    Set<String> inputWords = words.keySet();
    for(String word : inputWords) {
        tokenizer.setReader(new StringReader(word));
        TokenStream ts = filterFactory.create(tokenizer);

        CharTermAttribute term1 = ts.addAttribute(CharTermAttribute.class);
        ts.reset();
        assertThat(ts.incrementToken(), equalTo(true));
        assertThat(term1.toString(), equalTo(words.get(word)));
        ts.close();
    }
}
 
开发者ID:anaelcarvalho,项目名称:elasticsearch-analysis-metaphone_ptBR,代码行数:29,代码来源:MetaphoneTokenFilterTests.java


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