Package org.elasticsearch.common.xcontent

Examples of org.elasticsearch.common.xcontent.XContentParser.map()


    private Tuple<String, Map<String, Object>> extractMapping(String type, String source) throws MapperParsingException {
        Map<String, Object> root;
        XContentParser xContentParser = null;
        try {
            xContentParser = XContentFactory.xContent(source).createParser(source);
            root = xContentParser.map();
        } catch (IOException e) {
            throw new MapperParsingException("Failed to parse mapping definition", e);
        } finally {
            if (xContentParser != null) {
                xContentParser.close();
View Full Code Here


        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {
                currentFieldName = parser.currentName();
            } else if (token == XContentParser.Token.START_OBJECT) {
                if ("params".equals(currentFieldName)) {
                    params = parser.map();
                }
            } else if (token.isValue()) {
                if ("script".equals(currentFieldName)) {
                    script = parser.text();
                } else if ("lang".equals(currentFieldName)) {
View Full Code Here

                currentFieldName = parser.currentName();
            } else if (token == XContentParser.Token.START_OBJECT) {
                if ("query".equals(currentFieldName)) {
                    query = parseContext.parseInnerQuery();
                } else if ("params".equals(currentFieldName)) {
                    vars = parser.map();
                }
            } else if (token == XContentParser.Token.START_ARRAY) {
                if ("filters".equals(currentFieldName)) {
                    while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
                        String script = null;
View Full Code Here

                currentFieldName = parser.currentName();
            } else if (token == XContentParser.Token.START_OBJECT) {
                if ("query".equals(currentFieldName)) {
                    query = parseContext.parseInnerQuery();
                } else if ("params".equals(currentFieldName)) {
                    vars = parser.map();
                }
            } else if (token.isValue()) {
                if ("script".equals(currentFieldName)) {
                    script = parser.text();
                } else if ("lang".equals(currentFieldName)) {
View Full Code Here

        }

        public Builder putMapping(String type, String source) throws IOException {
            XContentParser parser = XContentFactory.xContent(source).createParser(source);
            try {
                putMapping(new MappingMetaData(type, parser.map()));
            } finally {
                parser.close();
            }
            return this;
        }
View Full Code Here

            builder.startArray("mappings");
            for (Map.Entry<String, CompressedString> entry : indexTemplateMetaData.mappings().entrySet()) {
                byte[] data = entry.getValue().uncompressed();
                XContentParser parser = XContentFactory.xContent(data).createParser(data);
                Map<String, Object> mapping = parser.map();
                parser.close();
                builder.map(mapping);
            }
            builder.endArray();
View Full Code Here

        }
        byte[] source = source();
        XContentParser parser = null;
        try {
            parser = XContentFactory.xContent(source).createParser(source);
            sourceAsMap = parser.map();
            parser.close();
            return sourceAsMap;
        } catch (Exception e) {
            throw new ElasticSearchParseException("Failed to parse source to map", e);
        } finally {
View Full Code Here

                            builder.startObject("mappings");
                            for (Map.Entry<String, CompressedString> entry : templateMetaData.mappings().entrySet()) {
                                byte[] mappingSource = entry.getValue().uncompressed();
                                XContentParser parser = XContentFactory.xContent(mappingSource).createParser(mappingSource);
                                Map<String, Object> mapping = parser.map();
                                if (mapping.size() == 1 && mapping.containsKey(entry.getKey())) {
                                    // the type name is the root value, reduce it
                                    mapping = (Map<String, Object>) mapping.get(entry.getKey());
                                }
                                builder.field(entry.getKey());
View Full Code Here

                            builder.startObject("mappings");
                            for (Map.Entry<String, MappingMetaData> entry : indexMetaData.mappings().entrySet()) {
                                byte[] mappingSource = entry.getValue().source().uncompressed();
                                XContentParser parser = XContentFactory.xContent(mappingSource).createParser(mappingSource);
                                Map<String, Object> mapping = parser.map();
                                if (mapping.size() == 1 && mapping.containsKey(entry.getKey())) {
                                    // the type name is the root value, reduce it
                                    mapping = (Map<String, Object>) mapping.get(entry.getKey());
                                }
                                builder.field(entry.getKey());
View Full Code Here

                        builder.startObject("mappings");
                        for (Map.Entry<String, CompressedString> entry : indexMetaData.mappings().entrySet()) {
                            byte[] mappingSource = entry.getValue().uncompressed();
                            XContentParser parser = XContentFactory.xContent(mappingSource).createParser(mappingSource);
                            Map<String, Object> mapping = parser.map();
                            if (mapping.size() == 1 && mapping.containsKey(entry.getKey())) {
                                // the type name is the root value, reduce it
                                mapping = (Map<String, Object>) mapping.get(entry.getKey());
                            }
                            builder.field(entry.getKey());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.