本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentHelper.convertToJson方法的典型用法代码示例。如果您正苦于以下问题:Java XContentHelper.convertToJson方法的具体用法?Java XContentHelper.convertToJson怎么用?Java XContentHelper.convertToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.XContentHelper
的用法示例。
在下文中一共展示了XContentHelper.convertToJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExecute
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void testExecute() throws Exception {
String processorTag = randomAsciiOfLength(3);
String randomField = randomAsciiOfLength(3);
String randomTargetField = randomAsciiOfLength(2);
JsonProcessor jsonProcessor = new JsonProcessor(processorTag, randomField, randomTargetField, false);
Map<String, Object> document = new HashMap<>();
Map<String, Object> randomJsonMap = RandomDocumentPicks.randomSource(random());
XContentBuilder builder = JsonXContent.contentBuilder().map(randomJsonMap);
String randomJson = XContentHelper.convertToJson(builder.bytes(), false);
document.put(randomField, randomJson);
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document);
jsonProcessor.execute(ingestDocument);
Map<String, Object> jsonified = ingestDocument.getFieldValue(randomTargetField, Map.class);
assertIngestDocument(ingestDocument.getFieldValue(randomTargetField, Object.class), jsonified);
}
示例2: parseSource
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
public void parseSource(BytesReference source) throws SQLParseException {
XContentParser parser = null;
try {
if (source != null && source.length() != 0) {
parser = XContentFactory.xContent(source).createParser(source);
parse(parser);
}
validate();
} catch (Exception e) {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(source, false);
} catch (Throwable e1) {
// ignore
}
throw new SQLParseException("Failed to parse source [" + sSource + "]", e);
} finally {
if (parser != null) {
parser.close();
}
}
}
示例3: getSourceAsString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
/**
* The source of the document as string (can be <tt>null</tt>).
*/
public String getSourceAsString() {
if (source == null) {
return null;
}
try {
return XContentHelper.convertToJson(getSourceRef(), false);
} catch (IOException e) {
throw new ElasticsearchParseException("failed to convert source to a json string");
}
}
示例4: source
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
/**
* The mapping source definition.
*/
public PutMappingRequest source(BytesReference mappingSource, XContentType xContentType) {
Objects.requireNonNull(xContentType);
try {
this.source = XContentHelper.convertToJson(mappingSource, false, false, xContentType);
return this;
} catch (IOException e) {
throw new UncheckedIOException("failed to convert source to json", e);
}
}
示例5: readFrom
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
type = in.readOptionalString();
source = in.readString();
if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // TODO change to V_5_3 once backported
// we do not know the format from earlier versions so convert if necessary
source = XContentHelper.convertToJson(new BytesArray(source), false, false, XContentFactory.xContentType(source));
}
updateAllTypes = in.readBoolean();
readTimeout(in);
concreteIndex = in.readOptionalWriteable(Index::new);
}
示例6: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String source = "_na_";
try {
source = XContentHelper.convertToJson(content, false, xContentType);
} catch (Exception e) {
// ignore
}
return "put stored script {id [" + id + "]" + (lang != null ? ", lang [" + lang + "]" : "") + ", content [" + source + "]}";
}
示例7: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
if (source.length() > MAX_SOURCE_LENGTH_IN_TOSTRING) {
sSource = "n/a, actual length: [" + new ByteSizeValue(source.length()).toString() + "], max length: " +
new ByteSizeValue(MAX_SOURCE_LENGTH_IN_TOSTRING).toString();
} else {
sSource = XContentHelper.convertToJson(source, false);
}
} catch (Exception e) {
// ignore
}
return "index {[" + index + "][" + type + "][" + id + "], source[" + sSource + "]}";
}
示例8: sourceAsString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String sourceAsString() {
if (source == null) {
return null;
}
try {
return XContentHelper.convertToJson(sourceRef(), false);
} catch (IOException e) {
throw new ElasticsearchParseException("failed to convert source to a json string");
}
}
示例9: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(source, false);
} catch (Exception e) {
// ignore
}
return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types) + ", source[" + sSource + "]";
}
示例10: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
if (sourceBuilder != null) {
return sourceBuilder.toString();
}
if (request.source() != null) {
try {
return XContentHelper.convertToJson(request.source().toBytesArray(), false, true);
} catch (Exception e) {
return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
}
}
return new QuerySourceBuilder().toString();
}
示例11: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(source, false);
} catch (Exception e) {
// ignore
}
return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types) + ", source[" + sSource + "], explain:" + explain +
", rewrite:" + rewrite;
}
示例12: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(source, false);
} catch (Exception e) {
// ignore
}
return "index {[" + ScriptService.SCRIPT_INDEX + "][" + scriptLang + "][" + id + "], source[" + sSource + "]}";
}
示例13: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
if (sourceBuilder != null) {
return sourceBuilder.toString();
}
if (request.source() != null) {
try {
return XContentHelper.convertToJson(request.source().toBytesArray(), false, true);
} catch (Exception e) {
return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}";
}
}
return new SearchSourceBuilder().toString();
}
示例14: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(suggestSource, false);
} catch (Exception e) {
// ignore
}
return "[" + Arrays.toString(indices) + "]" + ", suggestSource[" + sSource + "]";
}
示例15: toString
import org.elasticsearch.common.xcontent.XContentHelper; //导入方法依赖的package包/类
@Override
public String toString() {
String sSource = "_na_";
try {
sSource = XContentHelper.convertToJson(searchRequest.source(), false);
} catch (IOException e) {
// ignore
}
return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types()) + ", source[" + sSource + "]";
}