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


Java ShardId.getIndex方法代码示例

本文整理汇总了Java中org.elasticsearch.index.shard.ShardId.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ShardId.getIndex方法的具体用法?Java ShardId.getIndex怎么用?Java ShardId.getIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.index.shard.ShardId的用法示例。


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

示例1: processShardRouting

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private void processShardRouting(Map<String, Map<String, List<Integer>>> routing, ShardRouting shardRouting, ShardId shardId) {
    String node;
    int id;
    String index = shardId.getIndex();

    if (shardRouting == null) {
        node = service.localNode().id();
        id = UnassignedShard.markUnassigned(shardId.id());
    } else {
        node = shardRouting.currentNodeId();
        id = shardRouting.id();
    }
    Map<String, List<Integer>> nodeMap = routing.get(node);
    if (nodeMap == null) {
        nodeMap = new TreeMap<>();
        routing.put(node, nodeMap);
    }

    List<Integer> shards = nodeMap.get(index);
    if (shards == null) {
        shards = new ArrayList<>();
        nodeMap.put(index, shards);
    }
    shards.add(id);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:SysShardsTableInfo.java

示例2: PendingDelete

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
/**
 * Creates a new pending delete of an index
 */
PendingDelete(ShardId shardId, IndexSettings settings) {
    this.index = shardId.getIndex();
    this.shardId = shardId.getId();
    this.settings = settings;
    this.deleteIndex = false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndicesService.java

示例3: getAndLoadIfNotPresent

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private BitSet getAndLoadIfNotPresent(final Query query, final LeafReaderContext context) throws IOException, ExecutionException {
    final Object coreCacheReader = context.reader().getCoreCacheKey();
    final ShardId shardId = ShardUtils.extractShardId(context.reader());
    if (shardId != null // can't require it because of the percolator
            && indexSettings.getIndex().equals(shardId.getIndex()) == false) {
        // insanity
        throw new IllegalStateException("Trying to load bit set for index " + shardId.getIndex()
                + " with cache of index " + indexSettings.getIndex());
    }
    Cache<Query, Value> filterToFbs = loadedFilters.computeIfAbsent(coreCacheReader, key -> {
        context.reader().addCoreClosedListener(BitsetFilterCache.this);
        return CacheBuilder.<Query, Value>builder().build();
    });

    return filterToFbs.computeIfAbsent(query, key -> {
        final IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(context);
        final IndexSearcher searcher = new IndexSearcher(topLevelContext);
        searcher.setQueryCache(null);
        final Weight weight = searcher.createNormalizedWeight(query, false);
        Scorer s = weight.scorer(context);
        final BitSet bitSet;
        if (s == null) {
            bitSet = null;
        } else {
            bitSet = BitSet.of(s.iterator(), context.reader().maxDoc());
        }

        Value value = new Value(bitSet, shardId);
        listener.onCache(shardId, value.bitset);
        return value;
    }).bitset;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:BitsetFilterCache.java

示例4: shardRoutingTable

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
/**
 * All shards for the provided {@link ShardId}
 * @return All the shard routing entries for the given index and shard id
 * @throws IndexNotFoundException if provided index does not exist
 * @throws ShardNotFoundException if provided shard id is unknown
 */
public IndexShardRoutingTable shardRoutingTable(ShardId shardId) {
    IndexRoutingTable indexRouting = index(shardId.getIndexName());
    if (indexRouting == null || indexRouting.getIndex().equals(shardId.getIndex()) == false) {
        throw new IndexNotFoundException(shardId.getIndex());
    }
    IndexShardRoutingTable shard = indexRouting.shard(shardId.id());
    if (shard == null) {
        throw new ShardNotFoundException(shardId);
    }
    return shard;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RoutingTable.java

示例5: createContext

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public CrateSearchContext createContext(
        int jobSearchContextId,
        IndexShard indexshard,
        Engine.Searcher engineSearcher,
        WhereClause whereClause) {

    ShardId shardId = indexshard.shardId();
    SearchShardTarget searchShardTarget = new SearchShardTarget(
            clusterService.state().nodes().localNodeId(),
            shardId.getIndex(),
            shardId.id()
    );
    IndexService indexService = indexshard.indexService();
    CrateSearchContext searchContext = new CrateSearchContext(
            jobSearchContextId,
            System.currentTimeMillis(),
            searchShardTarget,
            engineSearcher,
            indexService,
            indexshard,
            scriptService,
            pageCacheRecycler,
            bigArrays,
            threadPool.estimatedTimeInMillisCounter(),
            Optional.<Scroll>absent()
    );
    LuceneQueryBuilder.Context context = luceneQueryBuilder.convert(
            whereClause,  indexService.mapperService(), indexService.fieldData(), indexService.cache());
    searchContext.parsedQuery(new ParsedQuery(context.query(), EMPTY_NAMED_FILTERS));

    Float minScore = context.minScore();
    if (minScore != null) {
        searchContext.minimumScore(minScore);
    }

    return searchContext;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:SearchContextFactory.java

示例6: ShardSchemaNameExpression

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
@Inject
public ShardSchemaNameExpression(ShardId shardId) {
    String indexName = shardId.getIndex();
    Matcher matcher = Schemas.SCHEMA_PATTERN.matcher(indexName);
    if (matcher.matches()) {
        schemaName = new BytesRef(matcher.group(1));
    } else {
        schemaName = DOC_SCHEMA_NAME;
    }

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:ShardSchemaNameExpression.java

示例7: ShardRequest

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public ShardRequest(ShardId shardId,
                    @Nullable String routing,
                    UUID jobId) {
    setShardId(shardId);
    this.routing = routing;
    this.jobId = jobId;
    this.index = shardId.getIndex();
    locations = new IntArrayList();
    items = new ArrayList<>();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ShardRequest.java

示例8: PendingDelete

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
/**
 * Creates a new pending delete of an index
 */
public PendingDelete(ShardId shardId, Settings settings) {
    this.index = shardId.getIndex();
    this.shardId = shardId.getId();
    this.settings = settings;
    this.deleteIndex = false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:IndicesService.java

示例9: ShardSearchLocalRequest

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
public ShardSearchLocalRequest(ShardId shardId, int numberOfShards, SearchType searchType,
                               BytesReference source, String[] types, Boolean requestCache) {
    this.index = shardId.getIndex();
    this.shardId = shardId.id();
    this.numberOfShards = numberOfShards;
    this.searchType = searchType;
    this.source = source;
    this.types = types;
    this.requestCache = requestCache;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ShardSearchLocalRequest.java

示例10: getAndLoadIfNotPresent

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
private BitSet getAndLoadIfNotPresent(final Query query, final LeafReaderContext context) throws IOException, ExecutionException {
    final Object coreCacheReader = context.reader().getCoreCacheKey();
    final ShardId shardId = ShardUtils.extractShardId(context.reader());
    if (shardId != null // can't require it because of the percolator
            && index.getName().equals(shardId.getIndex()) == false) {
        // insanity
        throw new IllegalStateException("Trying to load bit set for index [" + shardId.getIndex()
                + "] with cache of index [" + index.getName() + "]");
    }
    Cache<Query, Value> filterToFbs = loadedFilters.get(coreCacheReader, new Callable<Cache<Query, Value>>() {
        @Override
        public Cache<Query, Value> call() throws Exception {
            context.reader().addCoreClosedListener(BitsetFilterCache.this);
            return CacheBuilder.newBuilder().build();
        }
    });
    return filterToFbs.get(query,new Callable<Value>() {
        @Override
        public Value call() throws Exception {
            final IndexReaderContext topLevelContext = ReaderUtil.getTopLevelContext(context);
            final IndexSearcher searcher = new IndexSearcher(topLevelContext);
            searcher.setQueryCache(null);
            final Weight weight = searcher.createNormalizedWeight(query, false);
            final Scorer s = weight.scorer(context);
            final BitSet bitSet;
            if (s == null) {
                bitSet = null;
            } else {
                bitSet = BitSet.of(s.iterator(), context.reader().maxDoc());
            }

            Value value = new Value(bitSet, shardId);
            listener.onCache(shardId, value.bitset);
            return value;
        }
    }).bitset;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:38,代码来源:BitsetFilterCache.java

示例11: shardOperation

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
@Override
protected ExplainResponse shardOperation(ExplainRequest request, ShardId shardId) {
    IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
    IndexShard indexShard = indexService.shardSafe(shardId.id());
    Term uidTerm = new Term(UidFieldMapper.NAME, Uid.createUidAsBytes(request.type(), request.id()));
    Engine.GetResult result = indexShard.get(new Engine.Get(false, uidTerm));
    if (!result.exists()) {
        return new ExplainResponse(shardId.getIndex(), request.type(), request.id(), false);
    }

    SearchContext context = new DefaultSearchContext(
            0, new ShardSearchLocalRequest(new String[]{request.type()}, request.nowInMillis, request.filteringAlias()),
            null, result.searcher(), indexService, indexShard,
            scriptService, pageCacheRecycler,
            bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher,
            SearchService.NO_TIMEOUT
    );
    SearchContext.setCurrent(context);

    try {
        context.parsedQuery(indexService.queryParserService().parseQuery(request.source()));
        context.preProcess();
        int topLevelDocId = result.docIdAndVersion().docId + result.docIdAndVersion().context.docBase;
        Explanation explanation = context.searcher().explain(context.query(), topLevelDocId);
        for (RescoreSearchContext ctx : context.rescore()) {
            Rescorer rescorer = ctx.rescorer();
            explanation = rescorer.explain(topLevelDocId, context, ctx, explanation);
        }
        if (request.fields() != null || (request.fetchSourceContext() != null && request.fetchSourceContext().fetchSource())) {
            // Advantage is that we're not opening a second searcher to retrieve the _source. Also
            // because we are working in the same searcher in engineGetResult we can be sure that a
            // doc isn't deleted between the initial get and this call.
            GetResult getResult = indexShard.getService().get(result, request.id(), request.type(), request.fields(), request.fetchSourceContext(), false);
            return new ExplainResponse(shardId.getIndex(), request.type(), request.id(), true, explanation, getResult);
        } else {
            return new ExplainResponse(shardId.getIndex(), request.type(), request.id(), true, explanation);
        }
    } catch (IOException e) {
        throw new ElasticsearchException("Could not explain", e);
    } finally {
        context.close();
        SearchContext.removeCurrent();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:45,代码来源:TransportExplainAction.java

示例12: ReplicationRequest

import org.elasticsearch.index.shard.ShardId; //导入方法依赖的package包/类
/**
 * Creates a new request with resolved shard id
 */
public ReplicationRequest(ActionRequest request, ShardId shardId) {
    super(request);
    this.index = shardId.getIndex();
    this.shardId = shardId;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:ReplicationRequest.java


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