Package org.elasticsearch.index.mapper.Mapper

Examples of org.elasticsearch.index.mapper.Mapper.BuilderContext


        buildMapping(mapperBuilder);

        XContentBuilder contentBuilder = JsonXContent.contentBuilder();

        contentBuilder.startObject();
        mapperBuilder.build(new BuilderContext(null, new ContentPath())).toXContent(contentBuilder, null);
        contentBuilder.endObject();

        // cache mapping as string for easy debugging
        _mapping = contentBuilder.string();
      }
View Full Code Here


        buildMapping(mapperBuilder);

        XContentBuilder contentBuilder = JsonXContent.contentBuilder();

        contentBuilder.startObject();
        mapperBuilder.build(new BuilderContext(null, new ContentPath())).toXContent(contentBuilder, null,
            new ToXContent() {

              @Override
              public XContentBuilder toXContent(XContentBuilder builder, Params params)
                  throws IOException {
View Full Code Here

        buildMapping(mapperBuilder);

        XContentBuilder contentBuilder = JsonXContent.contentBuilder();

        contentBuilder.startObject();
        mapperBuilder.build(new BuilderContext(null, new ContentPath())).toXContent(contentBuilder,
            EMPTY_PARAMS, new ToXContent() {

              @Override
              public XContentBuilder toXContent(XContentBuilder builder, Params params)
                  throws IOException {
View Full Code Here

    public void testGetForFieldDefaults() {
        final IndexService indexService = createIndex("test");
        final IndexFieldDataService ifdService = indexService.fieldData();
        for (boolean docValues : Arrays.asList(true, false)) {
            final BuilderContext ctx = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1));
            final StringFieldMapper stringMapper = new StringFieldMapper.Builder("string").tokenized(false).fieldDataSettings(docValues ? DOC_VALUES_SETTINGS : ImmutableSettings.EMPTY).build(ctx);
            ifdService.clear();
            IndexFieldData<?> fd = ifdService.getForField(stringMapper);
            if (docValues) {
                assertTrue(fd instanceof SortedSetDVOrdinalsIndexFieldData);
View Full Code Here

    @SuppressWarnings("unchecked")
    public void testByPassDocValues() {
        final IndexService indexService = createIndex("test");
        final IndexFieldDataService ifdService = indexService.fieldData();
        final BuilderContext ctx = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1));
        final StringFieldMapper stringMapper = MapperBuilders.stringField("string").tokenized(false).fieldDataSettings(DOC_VALUES_SETTINGS).fieldDataSettings(ImmutableSettings.builder().put("format", "fst").build()).build(ctx);
        ifdService.clear();
        IndexFieldData<?> fd = ifdService.getForField(stringMapper);
        assertTrue(fd instanceof FSTBytesIndexFieldData);
View Full Code Here

    }

    public void testChangeFieldDataFormat() throws Exception {
        final IndexService indexService = createIndex("test");
        final IndexFieldDataService ifdService = indexService.fieldData();
        final BuilderContext ctx = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1));
        final StringFieldMapper mapper1 = MapperBuilders.stringField("s").tokenized(false).fieldDataSettings(ImmutableSettings.builder().put(FieldDataType.FORMAT_KEY, "paged_bytes").build()).build(ctx);
        final IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new KeywordAnalyzer()));
        Document doc = new Document();
        doc.add(new StringField("s", "thisisastring", Store.NO));
        writer.addDocument(doc);
View Full Code Here

            Mapper.TypeParser typeParser = parserContext.typeParser(type);
            if (typeParser == null) {
                throw new ElasticsearchIllegalArgumentException("No mapper found for type [" + type + "]");
            }
            final Mapper.Builder<?, ?> builder = typeParser.parse("__anonymous_" + type, ImmutableMap.<String, Object>of(), parserContext);
            final BuilderContext builderContext = new BuilderContext(indexSettings, new ContentPath(1));
            mapper = (FieldMapper<?>) builder.build(builderContext);

            // There is no need to synchronize writes here. In the case of concurrent access, we could just
            // compute some mappers several times, which is not a big deal
            this.unmappedFieldMappers = ImmutableMap.<String, FieldMapper<?>>builder()
View Full Code Here

        return getForField(getFieldDataType(), fieldName);
    }

    public <IFD extends IndexFieldData<?>> IFD getForField(FieldDataType type, String fieldName) {
        final FieldMapper<?> mapper;
        final BuilderContext context = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1));
        if (type.getType().equals("string")) {
            mapper = MapperBuilders.stringField(fieldName).tokenized(false).fieldDataSettings(type.getSettings()).build(context);
        } else if (type.getType().equals("float")) {
            mapper = MapperBuilders.floatField(fieldName).fieldDataSettings(type.getSettings()).build(context);
        } else if (type.getType().equals("double")) {
View Full Code Here

        assertThat(doc.rootDoc().getField("field6").fieldType().storeTermVectorPayloads(), equalTo(true));
    }

    public void testDocValues() throws Exception {
        // doc values only work on non-analyzed content
        final BuilderContext ctx = new BuilderContext(indexService.settingsService().getSettings(), new ContentPath(1));
        try {
            new StringFieldMapper.Builder("anything").fieldDataSettings(DOC_VALUES_SETTINGS).build(ctx);
            fail();
        } catch (Exception e) { /* OK */ }
        new StringFieldMapper.Builder("anything").tokenized(false).fieldDataSettings(DOC_VALUES_SETTINGS).build(ctx);
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.mapper.Mapper.BuilderContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.