Java Code Examples for org.elasticsearch.index.shard.IndexShard#mapperService()
The following examples show how to use
org.elasticsearch.index.shard.IndexShard#mapperService() .
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: LuceneShardCollectorProvider.java From crate with Apache License 2.0 | 5 votes |
public LuceneShardCollectorProvider(Schemas schemas, LuceneQueryBuilder luceneQueryBuilder, ClusterService clusterService, NodeJobsCounter nodeJobsCounter, Functions functions, ThreadPool threadPool, Settings settings, TransportActionProvider transportActionProvider, IndexShard indexShard, BigArrays bigArrays) { super( clusterService, schemas, nodeJobsCounter, functions, threadPool, settings, transportActionProvider, indexShard, new ShardRowContext(indexShard, clusterService) ); this.luceneQueryBuilder = luceneQueryBuilder; this.functions = functions; this.indexShard = indexShard; this.localNodeId = () -> clusterService.localNode().getId(); var mapperService = indexShard.mapperService(); fieldTypeLookup = mapperService::fullName; var relationName = RelationName.fromIndexName(indexShard.shardId().getIndexName()); this.table = schemas.getTableInfo(relationName, Operation.READ); this.docInputFactory = new DocInputFactory( functions, new LuceneReferenceResolver( indexShard.shardId().getIndexName(), fieldTypeLookup, table.partitionedByColumns() ) ); this.bigArrays = bigArrays; }
Example 2
Source File: BitsetFilterCache.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public IndicesWarmer.TerminationHandle warmNewReaders(final IndexShard indexShard, IndexMetaData indexMetaData, IndicesWarmer.WarmerContext context, ThreadPool threadPool) { if (index.getName().equals(context.shardId().getIndex()) == false) { // this is from a different index return TerminationHandle.NO_WAIT; } if (!loadRandomAccessFiltersEagerly) { return TerminationHandle.NO_WAIT; } boolean hasNested = false; final Set<Query> warmUp = new HashSet<>(); final MapperService mapperService = indexShard.mapperService(); for (DocumentMapper docMapper : mapperService.docMappers(false)) { if (docMapper.hasNestedObjects()) { hasNested = true; for (ObjectMapper objectMapper : docMapper.objectMappers().values()) { if (objectMapper.nested().isNested()) { ObjectMapper parentObjectMapper = docMapper.findParentObjectMapper(objectMapper); if (parentObjectMapper != null && parentObjectMapper.nested().isNested()) { warmUp.add(parentObjectMapper.nestedTypeFilter()); } } } } } if (hasNested) { warmUp.add(Queries.newNonNestedFilter()); } final Executor executor = threadPool.executor(executor()); final CountDownLatch latch = new CountDownLatch(context.searcher().reader().leaves().size() * warmUp.size()); for (final LeafReaderContext ctx : context.searcher().reader().leaves()) { for (final Query filterToWarm : warmUp) { executor.execute(new Runnable() { @Override public void run() { try { final long start = System.nanoTime(); getAndLoadIfNotPresent(filterToWarm, ctx); if (indexShard.warmerService().logger().isTraceEnabled()) { indexShard.warmerService().logger().trace("warmed bitset for [{}], took [{}]", filterToWarm, TimeValue.timeValueNanos(System.nanoTime() - start)); } } catch (Throwable t) { indexShard.warmerService().logger().warn("failed to load bitset for [{}]", t, filterToWarm); } finally { latch.countDown(); } } }); } } return new TerminationHandle() { @Override public void awaitTermination() throws InterruptedException { latch.await(); } }; }