本文整理了Java中org.elasticsearch.common.xcontent.XContentBuilder.bytes()
方法的一些代码示例,展示了XContentBuilder.bytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XContentBuilder.bytes()
方法的具体详情如下:
包路径:org.elasticsearch.common.xcontent.XContentBuilder
类名称:XContentBuilder
方法名:bytes
暂无
代码示例来源:origin: komoot/photon
@Override
public String convert(QueryBuilder anItem) {
try {
BytesReference bytes = anItem.toXContent(JsonXContent.contentBuilder(), new ToXContent.MapParams(null))
.bytes();
return bytes.utf8ToString();
} catch (IOException e) {
log.error("Unable to transform querybuilder to a json string due to an exception", e);
throw new RuntimeException("Unable to transform querybuilder to a json string due to an exception", e);
}
}
}
代码示例来源:origin: sirensolutions/siren-join
/**
* The query source to execute.
*/
public TermsByQueryRequest query(XContentBuilder builder) {
this.querySource = builder == null ? null : builder.bytes();
return this;
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Returns a string representation of the builder (only applicable for text based xcontent).
*/
public String string() throws IOException {
return bytes().utf8ToString();
}
代码示例来源:origin: harbby/presto-connectors
/**
* Sets the aliases that will be associated with the index when it gets created
*/
public CreateIndexRequest aliases(XContentBuilder source) {
return aliases(source.bytes());
}
代码示例来源:origin: org.elasticsearch.plugin/delete-by-query
/**
* Constructs a new builder with a raw search query.
*/
public DeleteByQueryRequestBuilder setQuery(XContentBuilder query) {
return setQuery(query.bytes());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
private static BytesReference toXContent(ToXContent result) throws IOException {
try (XContentBuilder builder = XContentFactory.contentBuilder(Requests.INDEX_CONTENT_TYPE)) {
// Elasticsearch's Response object never emit starting or ending objects. Most other implementers of ToXContent do....
builder.startObject();
result.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
return builder.bytes();
}
}
代码示例来源:origin: allegro/hermes
public static ElasticsearchDocument build(Callable<XContentBuilder> builder) {
try {
return new ElasticsearchDocument(builder.call().bytes());
} catch (Exception e) {
throw new ElasticsearchRepositoryException(e);
}
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* The template source definition.
*/
public PutIndexTemplateRequest source(XContentBuilder templateBuilder) {
try {
return source(templateBuilder.bytes(), templateBuilder.contentType());
} catch (Exception e) {
throw new IllegalArgumentException("Failed to build json for template request", e);
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Adds mapping that will be added when the index gets created.
*
* @param type The mapping type
* @param source The mapping source
*/
public CreateIndexRequest mapping(String type, XContentBuilder source) {
return mapping(type, source.bytes(), source.contentType());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Sets the content source to index.
*/
public IndexRequest source(XContentBuilder sourceBuilder) {
return source(sourceBuilder.bytes(), sourceBuilder.contentType());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Creates a new response based on {@link XContentBuilder}.
*/
public BytesRestResponse(RestStatus status, XContentBuilder builder) {
this(status, builder.contentType().mediaType(), builder.bytes());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public MappingMetaData(String type, Map<String, Object> mapping) throws IOException {
this.type = type;
XContentBuilder mappingBuilder = XContentFactory.jsonBuilder().map(mapping);
this.source = new CompressedXContent(mappingBuilder.bytes());
Map<String, Object> withoutType = mapping;
if (mapping.size() == 1 && mapping.containsKey(type)) {
withoutType = (Map<String, Object>) mapping.get(type);
}
initMappers(withoutType);
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public BytesReference source(IndexService indexService, DocumentMapper docMapper, Map sourceAsMap, Uid uid) throws JsonParseException, JsonMappingException, IOException {
if (docMapper.sourceMapper().enabled()) {
// retreive from _source columns stored as blob in cassandra if available.
ByteBuffer bb = (ByteBuffer) sourceAsMap.get(SourceFieldMapper.NAME);
if (bb != null)
return new BytesArray(bb.array(), bb.position(), bb.limit() - bb.position());
}
// rebuild _source from all cassandra columns.
XContentBuilder builder = buildDocument(docMapper, sourceAsMap, true, isStaticDocument(indexService, uid));
builder.humanReadable(true);
return builder.bytes();
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
public static Map<String, Object> convertToMap(ToXContent part) throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
part.toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return XContentHelper.convertToMap(builder.bytes(), false, builder.contentType()).v2();
}
代码示例来源:origin: yakaz/elasticsearch-action-updatebyquery
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);
}
}
}
代码示例来源:origin: jprante/elasticsearch-transport-websocket
public NettyInteractiveResponse(String type, XContentBuilder builder) throws IOException {
this.type = type;
XContentBuilder responseBuilder = jsonBuilder()
.startObject().field("success", true).field("type", type);
if (builder != null) {
responseBuilder.rawField("data", builder.bytes());
}
responseBuilder.endObject();
this.response = new TextWebSocketFrame(responseBuilder.string());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public void declareRawObject(BiConsumer<Value, BytesReference> consumer, ParseField field) {
CheckedFunction<XContentParser, BytesReference, IOException> bytesParser = p -> {
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
builder.prettyPrint();
builder.copyCurrentStructure(p);
return builder.bytes();
}
};
declareField(consumer, bytesParser, field, ValueType.OBJECT);
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
private static BytesReference parseSourceBytes(XContentParser parser) throws IOException {
try (XContentBuilder builder = XContentBuilder.builder(parser.contentType().xContent())) {
// the original document gets slightly modified: whitespaces or
// pretty printing are not preserved,
// it all depends on the current builder settings
builder.copyCurrentStructure(parser);
return builder.bytes();
}
}
代码示例来源:origin: com.bazaarvoice.elasticsearch.client/es-rest-client-core-1.4
public static BytesReference nodeBytesReferenceForMapValue(final @Nullable Map<String, ?> o) {
if (o == null) {
return null;
} else {
try {
return XContentFactory.jsonBuilder().map(o).bytes();
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
}
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
/**
* Create a new {@link XContentParser}.
*/
protected final XContentParser createParser(XContentBuilder builder) throws IOException {
return builder.generator().contentType().xContent().createParser(xContentRegistry(), builder.bytes());
}
内容来源于网络,如有侵权,请联系作者删除!