Search in sources :

Example 1 with BitsetFilterCache

use of org.elasticsearch.index.cache.bitset.BitsetFilterCache in project elasticsearch by elastic.

the class AbstractSortTestCase method createMockShardContext.

protected QueryShardContext createMockShardContext() {
    Index index = new Index(randomAsciiOfLengthBetween(1, 10), "_na_");
    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build());
    IndicesFieldDataCache cache = new IndicesFieldDataCache(Settings.EMPTY, null);
    IndexFieldDataService ifds = new IndexFieldDataService(IndexSettingsModule.newIndexSettings("test", Settings.EMPTY), cache, null, null);
    BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, new BitsetFilterCache.Listener() {

        @Override
        public void onRemoval(ShardId shardId, Accountable accountable) {
        }

        @Override
        public void onCache(ShardId shardId, Accountable accountable) {
        }
    });
    long nowInMillis = randomNonNegativeLong();
    return new QueryShardContext(0, idxSettings, bitsetFilterCache, ifds, null, null, scriptService, xContentRegistry(), null, null, () -> nowInMillis) {

        @Override
        public MappedFieldType fieldMapper(String name) {
            return provideMappedFieldType(name);
        }

        @Override
        public ObjectMapper getObjectMapper(String name) {
            BuilderContext context = new BuilderContext(this.getIndexSettings().getSettings(), new ContentPath());
            return new ObjectMapper.Builder<>(name).nested(Nested.newNested(false, false)).build(context);
        }
    };
}
Also used : IndexSettings(org.elasticsearch.index.IndexSettings) IdsQueryBuilder(org.elasticsearch.index.query.IdsQueryBuilder) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) MatchAllQueryBuilder(org.elasticsearch.index.query.MatchAllQueryBuilder) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) TermQueryBuilder(org.elasticsearch.index.query.TermQueryBuilder) Accountable(org.apache.lucene.util.Accountable) Index(org.elasticsearch.index.Index) ContentPath(org.elasticsearch.index.mapper.ContentPath) ShardId(org.elasticsearch.index.shard.ShardId) IndicesFieldDataCache(org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache) IndexFieldDataService(org.elasticsearch.index.fielddata.IndexFieldDataService) QueryShardContext(org.elasticsearch.index.query.QueryShardContext) BuilderContext(org.elasticsearch.index.mapper.Mapper.BuilderContext) BitsetFilterCache(org.elasticsearch.index.cache.bitset.BitsetFilterCache)

Aggregations

Accountable (org.apache.lucene.util.Accountable)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 Index (org.elasticsearch.index.Index)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 BitsetFilterCache (org.elasticsearch.index.cache.bitset.BitsetFilterCache)1 IndexFieldDataService (org.elasticsearch.index.fielddata.IndexFieldDataService)1 ContentPath (org.elasticsearch.index.mapper.ContentPath)1 BuilderContext (org.elasticsearch.index.mapper.Mapper.BuilderContext)1 IdsQueryBuilder (org.elasticsearch.index.query.IdsQueryBuilder)1 MatchAllQueryBuilder (org.elasticsearch.index.query.MatchAllQueryBuilder)1 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)1 QueryShardContext (org.elasticsearch.index.query.QueryShardContext)1 TermQueryBuilder (org.elasticsearch.index.query.TermQueryBuilder)1 ShardId (org.elasticsearch.index.shard.ShardId)1 IndicesFieldDataCache (org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache)1