• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DocumentMapperParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testEmptyName

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testEmptyName() throws Exception {
    // after 5.x
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
        .startObject("properties").startObject("").field("type", "percolator").endObject().endObject()
        .endObject().endObject().string();
    DocumentMapperParser parser = mapperService.documentMapperParser();

    IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
        () -> parser.parse("type1", new CompressedXContent(mapping))
    );
    assertThat(e.getMessage(), containsString("name cannot be empty string"));

    // before 5.x
    Version oldVersion = VersionUtils.randomVersionBetween(getRandom(), Version.V_2_0_0, Version.V_2_3_5);
    Settings oldIndexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, oldVersion).build();
    DocumentMapperParser parser2x = createIndex("test_old", oldIndexSettings).mapperService().documentMapperParser();

    DocumentMapper defaultMapper = parser2x.parse("type1", new CompressedXContent(mapping));
    assertEquals(mapping, defaultMapper.mappingSource().string());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:PercolatorFieldMapperTests.java


示例2: load

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
private static ContextMapping load(Map<String, Object> contextConfig, Version indexVersionCreated) {
    String name = extractRequiredValue(contextConfig, FIELD_NAME);
    String type = extractRequiredValue(contextConfig, FIELD_TYPE);
    final ContextMapping contextMapping;
    switch (Type.fromString(type)) {
        case CATEGORY:
            contextMapping = CategoryContextMapping.load(name, contextConfig);
            break;
        case GEO:
            contextMapping = GeoContextMapping.load(name, contextConfig);
            break;
        default:
            throw new ElasticsearchParseException("unknown context type[" + type + "]");
    }
    DocumentMapperParser.checkNoRemainingFields(name, contextConfig, indexVersionCreated);
    return contextMapping;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ContextMappings.java


示例3: test1Merge

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void test1Merge() throws Exception {

        String stage1Mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties")
                .startObject("name").field("type", "text").endObject()
                .endObject().endObject().endObject().string();
        DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
        DocumentMapper stage1 = parser.parse("person", new CompressedXContent(stage1Mapping));
        String stage2Mapping = XContentFactory.jsonBuilder().startObject().startObject("person").startObject("properties")
                .startObject("name").field("type", "text").endObject()
                .startObject("age").field("type", "integer").endObject()
                .startObject("obj1").startObject("properties").startObject("prop1").field("type", "integer").endObject().endObject().endObject()
                .endObject().endObject().endObject().string();
        DocumentMapper stage2 = parser.parse("person", new CompressedXContent(stage2Mapping));

        DocumentMapper merged = stage1.merge(stage2.mapping(), false);
        // stage1 mapping should not have been modified
        assertThat(stage1.mappers().smartNameFieldMapper("age"), nullValue());
        assertThat(stage1.mappers().smartNameFieldMapper("obj1.prop1"), nullValue());
        // but merged should
        assertThat(merged.mappers().smartNameFieldMapper("age"), notNullValue());
        assertThat(merged.mappers().smartNameFieldMapper("obj1.prop1"), notNullValue());
    }
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:DocumentMapperMergeTests.java


示例4: testMergeSearchAnalyzer

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testMergeSearchAnalyzer() throws Exception {
    DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    String mapping1 = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").field("search_analyzer", "whitespace").endObject().endObject()
            .endObject().endObject().string();
    String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("properties").startObject("field").field("type", "text").field("analyzer", "standard").field("search_analyzer", "keyword").endObject().endObject()
            .endObject().endObject().string();

    DocumentMapper existing = parser.parse("type", new CompressedXContent(mapping1));
    DocumentMapper changed = parser.parse("type", new CompressedXContent(mapping2));

    assertThat(((NamedAnalyzer) existing.mappers().getMapper("field").fieldType().searchAnalyzer()).name(), equalTo("whitespace"));
    DocumentMapper merged = existing.merge(changed.mapping(), false);

    assertThat(((NamedAnalyzer) merged.mappers().getMapper("field").fieldType().searchAnalyzer()).name(), equalTo("keyword"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:DocumentMapperMergeTests.java


示例5: loadMapping

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
protected static ContextMapping loadMapping(String name, Map<String, Object> config, Version indexVersionCreated)
        throws ElasticsearchParseException {
    final Object argType = config.get(ContextMapping.FIELD_TYPE);

    if (argType == null) {
        throw new ElasticsearchParseException("missing [{}] in context mapping", ContextMapping.FIELD_TYPE);
    }

    final String type = argType.toString();
    ContextMapping contextMapping;
    if (GeolocationContextMapping.TYPE.equals(type)) {
        contextMapping = GeolocationContextMapping.load(name, config);
    } else if (CategoryContextMapping.TYPE.equals(type)) {
        contextMapping = CategoryContextMapping.load(name, config);
    } else {
        throw new ElasticsearchParseException("unknown context type [{}]", type);
    }
    config.remove(ContextMapping.FIELD_TYPE);
    DocumentMapperParser.checkNoRemainingFields(name, config, indexVersionCreated);

    return contextMapping;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:ContextBuilder.java


示例6: newDocumentMapperParser

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public static DocumentMapperParser newDocumentMapperParser(Settings settings) {
    Settings forcedSettings = Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(settings)
            .build();
    SimilarityLookupService similarityLookupService = newSimilarityLookupService(forcedSettings);
    Map<String, Mapper.TypeParser> mappers = registerBuiltInMappers();
    Map<String, MetadataFieldMapper.TypeParser> metadataMappers = registerBuiltInMetadataMappers();
    MapperRegistry mapperRegistry = new MapperRegistry(mappers, metadataMappers);
    MapperService mapperService = new MapperService(new Index("test"),
            forcedSettings,
            newAnalysisService(forcedSettings),
            similarityLookupService,
            null,
            mapperRegistry);
    return new DocumentMapperParser(
            forcedSettings,
            mapperService,
            newAnalysisService(forcedSettings),
            similarityLookupService,
            null,
            mapperRegistry);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-opennlp,代码行数:24,代码来源:MapperTestUtils.java


示例7: setupMapperParser

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
@Before
public void setupMapperParser() {
    Index index = new Index("test");

    Map<String, AnalyzerProviderFactory> analyzerFactoryFactories = Maps.newHashMap();
    analyzerFactoryFactories.put("keyword", new PreBuiltAnalyzerProviderFactory("keyword", AnalyzerScope.INDEX, new KeywordAnalyzer()));
    AnalysisService analysisService = new AnalysisService(index, ImmutableSettings.Builder.EMPTY_SETTINGS, null, analyzerFactoryFactories, null, null, null);

    mapperParser = new DocumentMapperParser(index, analysisService, new PostingsFormatService(index),
            new SimilarityLookupService(index, ImmutableSettings.Builder.EMPTY_SETTINGS));
    Settings settings = settingsBuilder()
            .put("opennlp.models.name.file", "src/test/resources/models/en-ner-person.bin")
            .put("opennlp.models.date.file", "src/test/resources/models/en-ner-date.bin")
            .put("opennlp.models.location.file", "src/test/resources/models/en-ner-location.bin")
            .build();

    LogConfigurator.configure(settings);

    OpenNlpService openNlpService = new OpenNlpService(settings);
    openNlpService.start();
    mapperParser.putTypeParser(OpenNlpMapper.CONTENT_TYPE, new OpenNlpMapper.TypeParser(analysisService, openNlpService));
}
 
开发者ID:spinscale,项目名称:elasticsearch-opennlp-plugin,代码行数:23,代码来源:OpenNlpMappingTest.java


示例8: testSimilarityDefaultBackCompat

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testSimilarityDefaultBackCompat() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
        .startObject("properties")
        .startObject("field1")
        .field("similarity", "default")
        .field("type", "text")
        .endObject()
        .endObject()
        .endObject()
        .endObject().string();
    Settings settings = Settings.builder()
        .put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_2_0))
        .build();

    DocumentMapperParser parser = createIndex("test_v2.x", settings).mapperService().documentMapperParser();
    DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(mapping));
    assertThat(documentMapper.mappers().getMapper("field1").fieldType().similarity(), instanceOf(ClassicSimilarityProvider.class));
    assertThat(documentMapper.mappers().getMapper("field1").fieldType().similarity().name(), equalTo("classic"));

    parser = createIndex("test_v3.x").mapperService().documentMapperParser();
    try {
        parser.parse("type", new CompressedXContent(mapping));
        fail("Expected MappingParsingException");
    } catch (MapperParsingException e) {
        assertThat(e.getMessage(), equalTo("Unknown Similarity type [default] for field [field1]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:SimilarityTests.java


示例9: testIndexNotConfigurable

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testIndexNotConfigurable() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .startObject("_index").endObject()
            .endObject().endObject().string();
    DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    MapperParsingException e = expectThrows(MapperParsingException.class,
            () -> parser.parse("type", new CompressedXContent(mapping)));
    assertEquals("_index is not configurable", e.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndexFieldMapperTests.java


示例10: testTypeLevel

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testTypeLevel() throws Exception {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
            .endObject().endObject().string();

    DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
    assertThat(mapper.type(), equalTo("type"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:DocumentMapperParserTests.java


示例11: testFieldNameWithDots

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testFieldNameWithDots() throws Exception {
    IndexService indexService = createIndex("test");
    DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
        .startObject("foo.bar").field("type", "text").endObject()
        .startObject("foo.baz").field("type", "keyword").endObject()
        .endObject().endObject().endObject().string();
    DocumentMapper docMapper = mapperParser.parse("type", new CompressedXContent(mapping));
    assertNotNull(docMapper.mappers().getMapper("foo.bar"));
    assertNotNull(docMapper.mappers().getMapper("foo.baz"));
    assertNotNull(docMapper.objectMappers().get("foo"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:DocumentMapperParserTests.java


示例12: testFieldNameWithDeepDots

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testFieldNameWithDeepDots() throws Exception {
    IndexService indexService = createIndex("test");
    DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
        .startObject("foo.bar").field("type", "text").endObject()
        .startObject("foo.baz").startObject("properties")
        .startObject("deep.field").field("type", "keyword").endObject().endObject()
        .endObject().endObject().endObject().endObject().string();
    DocumentMapper docMapper = mapperParser.parse("type", new CompressedXContent(mapping));
    assertNotNull(docMapper.mappers().getMapper("foo.bar"));
    assertNotNull(docMapper.mappers().getMapper("foo.baz.deep.field"));
    assertNotNull(docMapper.objectMappers().get("foo"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:DocumentMapperParserTests.java


示例13: testFieldNameWithDotsConflict

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testFieldNameWithDotsConflict() throws Exception {
    IndexService indexService = createIndex("test");
    DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
        .startObject("foo").field("type", "text").endObject()
        .startObject("foo.baz").field("type", "keyword").endObject()
        .endObject().endObject().endObject().string();
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () ->
        mapperParser.parse("type", new CompressedXContent(mapping)));
    assertTrue(e.getMessage(), e.getMessage().contains("mapper [foo] of different type"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:DocumentMapperParserTests.java


示例14: testMergeObjectDynamic

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testMergeObjectDynamic() throws Exception {
    DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    String objectMapping = XContentFactory.jsonBuilder().startObject().startObject("type1").endObject().endObject().string();
    DocumentMapper mapper = parser.parse("type1", new CompressedXContent(objectMapping));
    assertNull(mapper.root().dynamic());

    String withDynamicMapping = XContentFactory.jsonBuilder().startObject().startObject("type1").field("dynamic", "false").endObject().endObject().string();
    DocumentMapper withDynamicMapper = parser.parse("type1", new CompressedXContent(withDynamicMapping));
    assertThat(withDynamicMapper.root().dynamic(), equalTo(ObjectMapper.Dynamic.FALSE));

    DocumentMapper merged = mapper.merge(withDynamicMapper.mapping(), false);
    assertThat(merged.root().dynamic(), equalTo(ObjectMapper.Dynamic.FALSE));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:DocumentMapperMergeTests.java


示例15: testObjectFieldNotAllowed

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testObjectFieldNotAllowed() throws Exception {
    String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field")
        .field("type", "text").startObject("fields").startObject("multi").field("type", "object").endObject().endObject()
        .endObject().endObject().endObject().endObject().string();
    final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    try {
        parser.parse("type", new CompressedXContent(mapping));
        fail("expected mapping parse failure");
    } catch (MapperParsingException e) {
        assertTrue(e.getMessage().contains("cannot be used in multi field"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MultiFieldTests.java


示例16: testNestedFieldNotAllowed

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public void testNestedFieldNotAllowed() throws Exception {
    String mapping = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("my_field")
        .field("type", "text").startObject("fields").startObject("multi").field("type", "nested").endObject().endObject()
        .endObject().endObject().endObject().endObject().string();
    final DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
    try {
        parser.parse("type", new CompressedXContent(mapping));
        fail("expected mapping parse failure");
    } catch (MapperParsingException e) {
        assertTrue(e.getMessage().contains("cannot be used in multi field"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MultiFieldTests.java


示例17: setup

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
@Before
public void setup() {
    indexService = createIndex("test");
    mapperRegistry = new MapperRegistry(
            Collections.singletonMap(Murmur3FieldMapper.CONTENT_TYPE, new Murmur3FieldMapper.TypeParser()),
            Collections.emptyMap());
    Supplier<QueryShardContext> queryShardContext = () -> {
        return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); });
    };
    parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(), indexService.getIndexAnalyzers(),
            indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:Murmur3FieldMapperTests.java


示例18: newDocumentMapperParser

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public static DocumentMapperParser newDocumentMapperParser(Settings customSettings, String index) throws IOException {
    Settings settings = Settings.builder()
            .put("path.home", System.getProperty("path.home", "/tmp"))
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(customSettings)
            .build();
    Environment environment = new Environment(settings);
    HyphenPlugin hyphenPlugin = new HyphenPlugin();
    AnalysisModule analysisModule = new AnalysisModule(environment, Collections.singletonList(hyphenPlugin));
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
    AnalysisRegistry analysisRegistry = analysisModule.getAnalysisRegistry();
    IndexMetaData indexMetaData = IndexMetaData.builder(index)
            .settings(settings)
            .numberOfShards(1)
            .numberOfReplicas(1)
            .build();
    IndexSettings indexSettings = new IndexSettings(indexMetaData, settings);
    SimilarityService similarityService = new SimilarityService(indexSettings, SimilarityService.BUILT_IN);
    Map<String, CharFilterFactory> charFilterFactoryMap = analysisRegistry.buildCharFilterFactories(indexSettings);
    Map<String, TokenFilterFactory> tokenFilterFactoryMap = analysisRegistry.buildTokenFilterFactories(indexSettings);
    Map<String, TokenizerFactory> tokenizerFactoryMap = analysisRegistry.buildTokenizerFactories(indexSettings);
    Map<String, AnalyzerProvider<?>> analyzerProviderMap = analysisRegistry.buildAnalyzerFactories(indexSettings);
    IndexAnalyzers indexAnalyzers = analysisRegistry.build(indexSettings, analyzerProviderMap,
            tokenizerFactoryMap, charFilterFactoryMap, tokenFilterFactoryMap);
    MapperService mapperService = new MapperService(indexSettings, indexAnalyzers,
            similarityService, mapperRegistry, null);
    return new DocumentMapperParser(indexSettings,
            mapperService, indexAnalyzers, similarityService, mapperRegistry, null);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-hyphen,代码行数:31,代码来源:MapperTestUtils.java


示例19: newDocumentMapperParser

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
public static DocumentMapperParser newDocumentMapperParser(Settings customSettings, String index) throws IOException {
    Settings settings = Settings.builder()
            .put("path.home", System.getProperty("path.home", System.getProperty("user.dir")))
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put(customSettings)
            .build();
    Environment environment = new Environment(settings);
    ReferencePlugin referencePlugin = new ReferencePlugin();
    AnalysisModule analysisModule = new AnalysisModule(environment, Collections.emptyList());
    IndicesModule indicesModule = new IndicesModule(Collections.singletonList(referencePlugin));
    MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
    AnalysisRegistry analysisRegistry = analysisModule.getAnalysisRegistry();
    IndexMetaData indexMetaData = IndexMetaData.builder(index)
            .settings(settings)
            .numberOfShards(1)
            .numberOfReplicas(1)
            .build();
    IndexSettings indexSettings = new IndexSettings(indexMetaData, settings);
    SimilarityService similarityService = new SimilarityService(indexSettings, SimilarityService.BUILT_IN);
    Map<String, CharFilterFactory> charFilterFactoryMap = analysisRegistry.buildCharFilterFactories(indexSettings);
    Map<String, TokenFilterFactory> tokenFilterFactoryMap = analysisRegistry.buildTokenFilterFactories(indexSettings);
    Map<String, TokenizerFactory> tokenizerFactoryMap = analysisRegistry.buildTokenizerFactories(indexSettings);
    Map<String, AnalyzerProvider<?>> analyzerProviderMap = analysisRegistry.buildAnalyzerFactories(indexSettings);
    Map<String, AnalyzerProvider<?>> normalizerProviderMap = analysisRegistry.buildNormalizerFactories(indexSettings);
    IndexAnalyzers indexAnalyzers = analysisRegistry.build(indexSettings,
            analyzerProviderMap,
            normalizerProviderMap,
            tokenizerFactoryMap,
            charFilterFactoryMap,
            tokenFilterFactoryMap);
    MapperService mapperService = new MapperService(indexSettings, indexAnalyzers, NamedXContentRegistry.EMPTY,
            similarityService, mapperRegistry, null);
    return new DocumentMapperParser(indexSettings, mapperService, indexAnalyzers, NamedXContentRegistry.EMPTY,
            similarityService, mapperRegistry, null);
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-reference,代码行数:36,代码来源:MapperTestUtils.java


示例20: testRefFromID

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入依赖的package包/类
@Test
public void testRefFromID() throws Exception {
    String mapping = copyToStringFromClasspath("ref-mapping-from-id.json");
    DocumentMapperParser mapperParser = newDocumentMapperParser("docs");
    DocumentMapper docMapper = mapperParser.parse("docs", new CompressedXContent(mapping));
    BytesReference json = jsonBuilder().startObject()
            .field("title", "A title")
            .field("authorID", "1")
            .endObject().bytes();
    ParseContext.Document doc = docMapper.parse("docs", "docs", "1", json).rootDoc();
    assertEquals(1, doc.getFields("ref").length, 1);
    assertEquals("John Doe", doc.getFields("ref")[0].stringValue());
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-reference,代码行数:14,代码来源:ReferenceMappingTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MD5MD5CRC32GzipFileChecksum类代码示例发布时间:2022-05-22
下一篇:
Java BoundValueOperations类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap