Package org.elasticsearch.common.xcontent

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


    private static final Settings SINGLE_SHARD_SETTINGS = ImmutableSettings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).build();

    private void test(IndexService indexService, boolean broken, FilterBuilder filterBuilder) throws IOException {
        client().admin().indices().prepareRefresh("test").get();
        XContentBuilder builder = filterBuilder.toXContent(JsonXContent.contentBuilder(), ToXContent.EMPTY_PARAMS);
        XContentParser parser = JsonXContent.jsonXContent.createParser(builder.bytes());
        Filter filter = indexService.queryParserService().parseInnerFilter(parser).filter();
        try (Searcher searcher = indexService.shardSafe(0).acquireSearcher("test")) {
            final LeafReaderContext ctx = searcher.reader().leaves().get(0);
            DocIdSet set = filter.getDocIdSet(ctx, null);
            assertEquals(broken, DocIdSets.isBroken(set.iterator()));
View Full Code Here


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