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


Java IndexService.getIndexSettings方法代码示例

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


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

示例1: testRewriteMissingReader

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testRewriteMissingReader() throws Exception {
    IndexService indexService = createIndex("test");
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties")
                .startObject("foo")
                    .field("type", "date")
                .endObject()
            .endObject()
        .endObject().endObject().string();
    indexService.mapperService().merge("type",
            new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false);
    QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), null, null, indexService.mapperService(),
            null, null, xContentRegistry(), null, null, null);
    RangeQueryBuilder range = new RangeQueryBuilder("foo");
    // can't make assumptions on a missing reader, so it must return INTERSECT
    assertEquals(Relation.INTERSECTS, range.getRelation(context));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RangeQueryRewriteTests.java

示例2: testRewriteEmptyReader

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testRewriteEmptyReader() throws Exception {
    IndexService indexService = createIndex("test");
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties")
                .startObject("foo")
                    .field("type", "date")
                .endObject()
            .endObject()
        .endObject().endObject().string();
    indexService.mapperService().merge("type",
            new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE, false);
    IndexReader reader = new MultiReader();
    QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), null, null, indexService.mapperService(),
            null, null, xContentRegistry(), null, reader, null);
    RangeQueryBuilder range = new RangeQueryBuilder("foo");
    // no values -> DISJOINT
    assertEquals(Relation.DISJOINT, range.getRelation(context));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RangeQueryRewriteTests.java

示例3: testRewriteMissingField

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testRewriteMissingField() throws Exception {
    IndexService indexService = createIndex("test");
    IndexReader reader = new MultiReader();
    QueryRewriteContext context = new QueryShardContext(0, indexService.getIndexSettings(), null, null, indexService.mapperService(),
            null, null, xContentRegistry(), null, reader, null);
    RangeQueryBuilder range = new RangeQueryBuilder("foo");
    assertEquals(Relation.DISJOINT, range.getRelation(context));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RangeQueryRewriteTests.java

示例4: newIndexShard

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public  static final IndexShard newIndexShard(IndexService indexService, IndexShard shard, IndexSearcherWrapper wrapper,
                                              IndexingOperationListener... listeners) throws IOException {
    ShardRouting initializingShardRouting = getInitializingShardRouting(shard.routingEntry());
    IndexShard newShard = new IndexShard(initializingShardRouting, indexService.getIndexSettings(), shard.shardPath(),
        shard.store(), indexService.cache(), indexService.mapperService(), indexService.similarityService(),
        indexService.fieldData(), shard.getEngineFactory(), indexService.getIndexEventListener(), wrapper,
        indexService.getThreadPool(), indexService.getBigArrays(), null, () -> {}, Collections.emptyList(), Arrays.asList(listeners));
    return newShard;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndexShardIT.java

示例5: testSeesFieldsFromPlugins

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testSeesFieldsFromPlugins() throws IOException {
    IndexService indexService = createIndex("test");
    IndicesModule indicesModule = newTestIndicesModule(
        Collections.emptyMap(),
        Collections.singletonMap("_dummy", new DummyMetadataFieldMapper.TypeParser())
    );
    final MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
    Supplier<QueryShardContext> queryShardContext = () -> {
        return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); });
    };
    MapperService mapperService = new MapperService(indexService.getIndexSettings(), indexService.getIndexAnalyzers(),
            indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
    DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), mapperService,
            indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
            queryShardContext);
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
    ParsedDocument parsedDocument = mapper.parse("index", "type", "id", new BytesArray("{}"));
    IndexableField[] fields = parsedDocument.rootDoc().getFields(FieldNamesFieldMapper.NAME);
    boolean found = false;
    for (IndexableField f : fields) {
        if ("_dummy".equals(f.stringValue())) {
            found = true;
            break;
        }
    }
    assertTrue("Could not find the dummy field among " + Arrays.toString(fields), found);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:FieldNamesFieldMapperTests.java

示例6: listStoreMetaData

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
private StoreFilesMetaData listStoreMetaData(ShardId shardId) throws IOException {
    logger.trace("listing store meta data for {}", shardId);
    long startTimeNS = System.nanoTime();
    boolean exists = false;
    try {
        IndexService indexService = indicesService.indexService(shardId.getIndex());
        if (indexService != null) {
            IndexShard indexShard = indexService.getShardOrNull(shardId.id());
            if (indexShard != null) {
                exists = true;
                return new StoreFilesMetaData(shardId, indexShard.snapshotStoreMetadata());
            }
        }
        // try and see if we an list unallocated
        IndexMetaData metaData = clusterService.state().metaData().index(shardId.getIndex());
        if (metaData == null) {
            // we may send this requests while processing the cluster state that recovered the index
            // sometimes the request comes in before the local node processed that cluster state
            // in such cases we can load it from disk
            metaData = IndexMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY,
                nodeEnv.indexPaths(shardId.getIndex()));
        }
        if (metaData == null) {
            logger.trace("{} node doesn't have meta data for the requests index, responding with empty", shardId);
            return new StoreFilesMetaData(shardId, Store.MetadataSnapshot.EMPTY);
        }
        final IndexSettings indexSettings = indexService != null ? indexService.getIndexSettings() : new IndexSettings(metaData, settings);
        final ShardPath shardPath = ShardPath.loadShardPath(logger, nodeEnv, shardId, indexSettings);
        if (shardPath == null) {
            return new StoreFilesMetaData(shardId, Store.MetadataSnapshot.EMPTY);
        }
        // note that this may fail if it can't get access to the shard lock. Since we check above there is an active shard, this means:
        // 1) a shard is being constructed, which means the master will not use a copy of this replica
        // 2) A shard is shutting down and has not cleared it's content within lock timeout. In this case the master may not
        //    reuse local resources.
        return new StoreFilesMetaData(shardId, Store.readMetadataSnapshot(shardPath.resolveIndex(), shardId,
            nodeEnv::shardLock, logger));
    } finally {
        TimeValue took = new TimeValue(System.nanoTime() - startTimeNS, TimeUnit.NANOSECONDS);
        if (exists) {
            logger.debug("{} loaded store meta data (took [{}])", shardId, took);
        } else {
            logger.trace("{} didn't find any store meta data to load (took [{}])", shardId, took);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:47,代码来源:TransportNodesListShardStoreMetaData.java

示例7: testExternalValues

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testExternalValues() throws Exception {
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    IndexService indexService = createIndex("test", settings);
    MapperRegistry mapperRegistry = new MapperRegistry(
            Collections.singletonMap(ExternalMapperPlugin.EXTERNAL, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "foo")),
            Collections.singletonMap(ExternalMetadataMapper.CONTENT_TYPE, new ExternalMetadataMapper.TypeParser()));

    Supplier<QueryShardContext> queryShardContext = () -> {
        return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); });
    };
    DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
            indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
            queryShardContext);
    DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
            XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject(ExternalMetadataMapper.CONTENT_TYPE)
            .endObject()
            .startObject("properties")
                .startObject("field").field("type", "external").endObject()
            .endObject()
        .endObject().endObject().string()
    ));

    ParsedDocument doc = documentMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
                .field("field", "1234")
            .endObject()
            .bytes());

    assertThat(doc.rootDoc().getField("field.bool"), notNullValue());
    assertThat(doc.rootDoc().getField("field.bool").stringValue(), is("T"));

    assertThat(doc.rootDoc().getField("field.point"), notNullValue());
    GeoPoint point = new GeoPoint().resetFromIndexableField(doc.rootDoc().getField("field.point"));
    assertThat(point.lat(), closeTo(42.0, 1e-5));
    assertThat(point.lon(), closeTo(51.0, 1e-5));

    assertThat(doc.rootDoc().getField("field.shape"), notNullValue());

    assertThat(doc.rootDoc().getField("field.field"), notNullValue());
    assertThat(doc.rootDoc().getField("field.field").stringValue(), is("foo"));

    assertThat(doc.rootDoc().getField(ExternalMetadataMapper.FIELD_NAME).stringValue(), is(ExternalMetadataMapper.FIELD_VALUE));

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

示例8: testExternalValuesWithMultifieldTwoLevels

import org.elasticsearch.index.IndexService; //导入方法依赖的package包/类
public void testExternalValuesWithMultifieldTwoLevels() throws Exception {
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    IndexService indexService = createIndex("test", settings);
    Map<String, Mapper.TypeParser> mapperParsers = new HashMap<>();
    mapperParsers.put(ExternalMapperPlugin.EXTERNAL, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "foo"));
    mapperParsers.put(ExternalMapperPlugin.EXTERNAL_BIS, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "bar"));
    mapperParsers.put(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser());
    MapperRegistry mapperRegistry = new MapperRegistry(mapperParsers, Collections.emptyMap());

    Supplier<QueryShardContext> queryShardContext = () -> {
        return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); });
    };
    DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
            indexService.getIndexAnalyzers(), indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry,
            queryShardContext);

    DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
            XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
            .startObject("field")
                .field("type", ExternalMapperPlugin.EXTERNAL)
                .startObject("fields")
                    .startObject("field")
                        .field("type", "text")
                        .startObject("fields")
                            .startObject("generated")
                                .field("type", ExternalMapperPlugin.EXTERNAL_BIS)
                            .endObject()
                            .startObject("raw")
                                .field("type", "text")
                            .endObject()
                        .endObject()
                    .endObject()
                    .startObject("raw")
                        .field("type", "text")
                    .endObject()
                .endObject()
            .endObject()
            .endObject().endObject().endObject()
            .string()));

    ParsedDocument doc = documentMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
            .startObject()
            .field("field", "1234")
            .endObject()
            .bytes());

    assertThat(doc.rootDoc().getField("field.bool"), notNullValue());
    assertThat(doc.rootDoc().getField("field.bool").stringValue(), is("T"));

    assertThat(doc.rootDoc().getField("field.point"), notNullValue());

    assertThat(doc.rootDoc().getField("field.shape"), notNullValue());

    assertThat(doc.rootDoc().getField("field.field"), notNullValue());
    assertThat(doc.rootDoc().getField("field.field").stringValue(), is("foo"));

    assertThat(doc.rootDoc().getField("field.field.generated.generated"), notNullValue());
    assertThat(doc.rootDoc().getField("field.field.generated.generated").stringValue(), is("bar"));

    assertThat(doc.rootDoc().getField("field.field.raw"), notNullValue());
    assertThat(doc.rootDoc().getField("field.field.raw").stringValue(), is("foo"));

    assertThat(doc.rootDoc().getField("field.raw"), notNullValue());
    assertThat(doc.rootDoc().getField("field.raw").stringValue(), is("foo"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:67,代码来源:ExternalFieldMapperTests.java


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