Package org.elasticsearch.common.xcontent

Examples of org.elasticsearch.common.xcontent.XContentBuilder.bytes()


                // symbol is no input
                throw new ColumnValidationException(columnIdent.name(),
                        String.format("invalid value '%s' in insert statement", valuesSymbol.toString()));
            }
        }
        context.sourceMaps().add(builder.bytes());
        context.addIdAndRouting(primaryKeyValues, routingValue);
    }

    private void addPrimaryKeyValue(int index, Object value, List<BytesRef> primaryKeyValues) {
        if (value == null) {
View Full Code Here


        builder.field("from", node.offset());
        builder.field("size", node.limit());

        builder.endObject();
        return builder.bytes();
    }

    /**
     * use to create a full elasticsearch query "statement" used by deleteByQuery actions.
     */
 
View Full Code Here

        XContentBuilder builder = context.builder;

        whereClause(context, node.whereClause());

        builder.endObject();
        return builder.bytes();
    }

    public BytesReference convert(ESUpdateNode node) throws IOException {
        assert node != null;
View Full Code Here

        if (node.version().isPresent()) {
            builder.field("version", node.version().get());
        }

        builder.endObject().endObject().endObject();
        return builder.bytes();
    }

    static class Context {
        XContentBuilder builder;
        final Map<String, Object> ignoredFields = new HashMap<>();
View Full Code Here

                File settingsFile = new File(context.outputFile() + ".settings");
                if (!context.forceOverride() && settingsFile.exists()) {
                    throw new IOException("File exists: " + settingsFile.getAbsolutePath());
                }
                OutputStream os = new FileOutputStream(settingsFile);
                os.write(builder.bytes().toBytes());
                os.flush();
                os.close();
            } catch (IOException e) {
                throw new ExportException(context, "Failed to write settings for index " + indexMetaData.index(), e);
            }
View Full Code Here

                File mappingsFile = new File(context.outputFile() + ".mapping");
                if (!context.forceOverride() && mappingsFile.exists()) {
                    throw new IOException("File exists: " + mappingsFile.getAbsolutePath());
                }
                OutputStream os = new FileOutputStream(mappingsFile);
                os.write(builder.bytes().toBytes());
                os.flush();
                os.close();
            } catch (IOException e) {
                throw new ExportException(context, "Failed to write mappings for index " + indexMetaData.index(), e);
            }
View Full Code Here

        builder.startObject();
        builder.startArray("docs");
        item.toXContent(builder, ToXContent.EMPTY_PARAMS);
        builder.endArray();
        builder.endObject();
        return XContentHelper.convertToJson(builder.bytes(), false);
    }

    private MultiGetRequest.Item JSONtoItem(String json) throws Exception {
        MultiGetRequest request = new MultiGetRequest().add(null, null, null, null, new BytesArray(json), true);
        return request.getItems().get(0);
View Full Code Here

        }
        builder.endArray();
        builder.endObject();

        // verify generated JSON lead to the same items
        String json = XContentHelper.convertToJson(builder.bytes(), false);
        testItemsFromJSON(json);
    }

}
View Full Code Here

     */
    public BytesReference buildAsBytes(XContentType contentType) {
        try {
            XContentBuilder builder = XContentFactory.contentBuilder(contentType);
            toXContent(builder, ToXContent.EMPTY_PARAMS);
            return builder.bytes();
        } catch (Exception e) {
            throw new SuggestBuilderException("Failed to build suggest query", e);
        }
    }

View Full Code Here

        public BytesReference buildAsBytes(XContentType contentType) {
            try {
                XContentBuilder builder = XContentFactory.contentBuilder(contentType);
                toXContent(builder, ToXContent.EMPTY_PARAMS);
                return builder.bytes();
            } catch (Exception e) {
                throw new SuggestBuilderException("Failed to build suggest", e);
            }
        }
    }
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.