Examples of copiedBytes()


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

        // introduce the doc
        XContentBuilder doc = XContentFactory.jsonBuilder().startObject().startObject("doc")
                .field("field1", 1)
                .field("field2", "value")
                .endObject().endObject();
        byte[] source = doc.copiedBytes();

        XContentBuilder docWithType = XContentFactory.jsonBuilder().startObject().startObject("doc").startObject("type1")
                .field("field1", 1)
                .field("field2", "value")
                .endObject().endObject().endObject();
View Full Code Here

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

        XContentBuilder docWithType = XContentFactory.jsonBuilder().startObject().startObject("doc").startObject("type1")
                .field("field1", 1)
                .field("field2", "value")
                .endObject().endObject().endObject();
        byte[] sourceWithType = docWithType.copiedBytes();

        PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));
        assertThat(percolate.matches(), hasSize(0));

        // add a query
View Full Code Here

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

        builder.field("field1", "value1");
        builder.rawField("_source", XContentFactory.unCachedContentBuilder(type).startObject().field("s_field", "s_value").endObject().copiedBytes());
        builder.field("field2", "value2");
        builder.endObject();

        XContentParser parser = XContentFactory.xContent(type).createParser(builder.copiedBytes());
        assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));
        assertThat(parser.nextToken(), equalTo(XContentParser.Token.FIELD_NAME));
        assertThat(parser.currentName(), equalTo("field1"));
        assertThat(parser.nextToken(), equalTo(XContentParser.Token.VALUE_STRING));
        assertThat(parser.text(), equalTo("value1"));
View Full Code Here

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

        XContentBuilder doc = XContentFactory.jsonBuilder().startObject().startObject("doc")
                .field("field1", 1)
                .field("field2", "value")
                .field("field3", "the quick brown fox jumped over the lazy dog")
                .endObject().endObject();
        final byte[] source = doc.copiedBytes();

        PercolatorExecutor.Response percolate = percolatorExecutor.percolate(new PercolatorExecutor.SourceRequest("type1", source));

        for (int i = 0; i < NUMBER_OF_QUERIES; i++) {
            percolatorExecutor.addQuery("test" + i, termQuery("field3", "quick"));
View Full Code Here

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

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

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

    public static CommitPoint fromXContent(byte[] data) throws Exception {
        XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(data);
        try {
View Full Code Here

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

    public byte[] buildAsBytes(XContentType contentType) throws SearchSourceBuilderException {
        try {
            XContentBuilder builder = XContentFactory.contentBuilder(contentType);
            toXContent(builder, EMPTY_PARAMS);
            return builder.copiedBytes();
        } catch (Exception e) {
            throw new SearchSourceBuilderException("Failed to build search source", e);
        }
    }
View Full Code Here

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

    @Override public byte[] buildAsBytes(XContentType contentType) throws QueryBuilderException {
        try {
            XContentBuilder builder = XContentFactory.contentBuilder(contentType);
            toXContent(builder, EMPTY_PARAMS);
            return builder.copiedBytes();
        } catch (Exception e) {
            throw new QueryBuilderException("Failed to build query", 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.