Package org.elasticsearch.common.compress

Examples of org.elasticsearch.common.compress.CompressedString


    public static CompressedString filter(FilterBuilder filterBuilder) throws IOException {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        filterBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS);
        builder.close();
        return new CompressedString(builder.string());
    }
View Full Code Here


        try {
            XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
            builder.startObject();
            toXContent(builder, ToXContent.EMPTY_PARAMS);
            builder.endObject();
            this.mappingSource = new CompressedString(builder.string());
        } catch (Exception e) {
            throw new FailedToGenerateSourceMapperException(e.getMessage(), e);
        }
    }
View Full Code Here

            }

            // go over and add the relevant mappings (or update them)
            for (MappingMetaData mappingMd : indexMetaData.mappings().values()) {
                String mappingType = mappingMd.type();
                CompressedString mappingSource = mappingMd.source();
                if (mappingType.equals(MapperService.DEFAULT_MAPPING)) { // we processed _default_ first
                    continue;
                }
                boolean requireRefresh = processMapping(event, index, mapperService, mappingType, mappingSource);
                if (requireRefresh) {
View Full Code Here

* @author kimchy (shay.banon)
*/
public class ParseRoutingTests {

    @Test public void testParseRouting() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Routing(true, "test"));
        byte[] bytes = jsonBuilder().startObject().field("aaa", "wr").field("test", "value").field("zzz", "wr").endObject().copiedBytes();
        assertThat(md.parseRouting(XContentFactory.xContent(bytes).createParser(bytes)), equalTo("value"));

        bytes = jsonBuilder().startObject()
                .field("aaa", "wr")
View Full Code Here

                .endObject().copiedBytes();
        assertThat(md.parseRouting(XContentFactory.xContent(bytes).createParser(bytes)), equalTo("value"));
    }

    @Test public void testParseRoutingWithPath() throws Exception {
        MappingMetaData md = new MappingMetaData("type1", new CompressedString(""), new MappingMetaData.Routing(true, "obj1.field2"));

        byte[] bytes = jsonBuilder().startObject()
                .field("aaa", "wr")
                .array("arr1", "1", "2", "3")
                .startObject("obj1").field("field1", "value1").field("field2", "value2").endObject()
View Full Code Here

                        // do the actual merge here on the master, and update the mapping source
                        DocumentMapper newMapper = entry.getValue();
                        if (existingMappers.containsKey(entry.getKey())) {
                            // we have an existing mapping, do the merge here (on the master), it will automatically update the mapping source
                            DocumentMapper existingMapper = existingMappers.get(entry.getKey());
                            CompressedString existingSource = existingMapper.mappingSource();

                            existingMapper.merge(newMapper, mergeFlags().simulate(false));

                            CompressedString updatedSource = existingMapper.mappingSource();
                            if (existingSource.equals(updatedSource)) {
                                // same source, no changes, ignore it
                            } else {
                                // use the merged mapping source
                                mappings.put(index, new MappingMetaData(existingMapper));
                                if (logger.isDebugEnabled()) {
                                    logger.debug("[{}] update_mapping [{}] with source [{}]", index, existingMapper.type(), updatedSource);
                                } else if (logger.isInfoEnabled()) {
                                    logger.info("[{}] update_mapping [{}]", index, existingMapper.type());
                                }
                            }
                        } else {
                            CompressedString newSource = newMapper.mappingSource();
                            mappings.put(index, new MappingMetaData(newMapper));
                            if (logger.isDebugEnabled()) {
                                logger.debug("[{}] create_mapping [{}] with source [{}]", index, newMapper.type(), newSource);
                            } else if (logger.isInfoEnabled()) {
                                logger.info("[{}] create_mapping [{}]", index, newMapper.type());
View Full Code Here

            mappings.put(mappingType, mappingSource);
            return this;
        }

        public Builder putMapping(String mappingType, String mappingSource) throws IOException {
            mappings.put(mappingType, new CompressedString(mappingSource));
            return this;
        }
View Full Code Here

        this.routing = new Routing(docMapper.routingFieldMapper().required(), docMapper.routingFieldMapper().path());
    }

    public MappingMetaData(String type, Map<String, Object> mapping) throws IOException {
        this.type = type;
        this.source = new CompressedString(XContentFactory.jsonBuilder().map(mapping).string());
        Map<String, Object> withoutType = mapping;
        if (mapping.size() == 1 && mapping.containsKey(type)) {
            withoutType = (Map<String, Object>) mapping.get(type);
        }
        if (withoutType.containsKey("_routing")) {
View Full Code Here

        }
    }

    public static MappingMetaData readFrom(StreamInput in) throws IOException {
        String type = in.readUTF();
        CompressedString source = CompressedString.readCompressedString(in);
        // routing
        Routing routing = new Routing(in.readBoolean(), in.readBoolean() ? in.readUTF() : null);
        return new MappingMetaData(type, source, routing);
    }
View Full Code Here

            if (filter == null || filter.isEmpty()) {
                this.filter = null;
                return this;
            }
            try {
                this.filter = new CompressedString(XContentFactory.jsonBuilder().map(filter).string());
                return this;
            } catch (IOException e) {
                throw new ElasticSearchGenerationException("Failed to build json for alias request", e);
            }
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.compress.CompressedString

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.