本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentBuilder.endObject方法的典型用法代码示例。如果您正苦于以下问题:Java XContentBuilder.endObject方法的具体用法?Java XContentBuilder.endObject怎么用?Java XContentBuilder.endObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.xcontent.XContentBuilder
的用法示例。
在下文中一共展示了XContentBuilder.endObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParseDist
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* test correct parsing of `dist` parameter, this should create builder with pre/post set to same value
*/
public void testParseDist() throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
builder.startObject(SpanNotQueryBuilder.NAME);
builder.field("exclude");
spanTermQuery("description", "jumped").toXContent(builder, null);
builder.field("include");
spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1)
.addClause(QueryBuilders.spanTermQuery("description", "fox")).toXContent(builder, null);
builder.field("dist", 3);
builder.endObject();
builder.endObject();
SpanNotQueryBuilder query = (SpanNotQueryBuilder)parseQuery(builder.string());
assertThat(query.pre(), equalTo(3));
assertThat(query.post(), equalTo(3));
assertNotNull(query.includeQuery());
assertNotNull(query.excludeQuery());
}
示例2: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.startObject(opType.getLowercase());
if (failure == null) {
response.innerToXContent(builder, params);
builder.field(STATUS, response.status().getStatus());
} else {
builder.field(_INDEX, failure.getIndex());
builder.field(_TYPE, failure.getType());
builder.field(_ID, failure.getId());
builder.field(STATUS, failure.getStatus().getStatus());
builder.startObject(ERROR);
ElasticsearchException.generateThrowableXContent(builder, params, failure.getCause());
builder.endObject();
}
builder.endObject();
builder.endObject();
return builder;
}
示例3: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(simpleName())
.field(Fields.TYPE, CONTENT_TYPE);
builder.field(Fields.ANALYZER, fieldType().indexAnalyzer().name());
if (fieldType().indexAnalyzer().name().equals(fieldType().searchAnalyzer().name()) == false) {
builder.field(Fields.SEARCH_ANALYZER.getPreferredName(), fieldType().searchAnalyzer().name());
}
builder.field(Fields.PAYLOADS, fieldType().analyzingSuggestLookupProvider.hasPayloads());
builder.field(Fields.PRESERVE_SEPARATORS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreserveSep());
builder.field(Fields.PRESERVE_POSITION_INCREMENTS.getPreferredName(), fieldType().analyzingSuggestLookupProvider.getPreservePositionsIncrements());
builder.field(Fields.MAX_INPUT_LENGTH.getPreferredName(), this.maxInputLength);
multiFields.toXContent(builder, params);
if (fieldType().requiresContext()) {
builder.startObject(Fields.CONTEXT);
for (ContextMapping mapping : fieldType().getContextMapping().values()) {
builder.value(mapping);
}
builder.endObject();
}
return builder.endObject();
}
示例4: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields._SHARDS);
builder.field(Fields.TOTAL, total);
builder.field(Fields.SUCCESSFUL, successful);
builder.field(Fields.FAILED, getFailed());
if (failures.length > 0) {
builder.startArray(Fields.FAILURES);
for (Failure failure : failures) {
failure.toXContent(builder, params);
}
builder.endArray();
}
builder.endObject();
return builder;
}
示例5: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Integer.toString(id));
builder.field("description", description);
builder.field("retryable", retryable);
if (disableStatePersistence) {
builder.field("disable_state_persistence", disableStatePersistence);
}
builder.startArray("levels");
for (ClusterBlockLevel level : levels) {
builder.value(level.name().toLowerCase(Locale.ROOT));
}
builder.endArray();
builder.endObject();
return builder;
}
示例6: buildXContentBuilder
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public static RestResponse buildXContentBuilder(Table table, RestChannel channel) throws Exception {
RestRequest request = channel.request();
XContentBuilder builder = channel.newBuilder();
List<DisplayHeader> displayHeaders = buildDisplayHeaders(table, request);
builder.startArray();
for (int row = 0; row < table.getRows().size(); row++) {
builder.startObject();
for (DisplayHeader header : displayHeaders) {
builder.field(header.display, renderValue(request, table.getAsMap().get(header.name).get(row).value));
}
builder.endObject();
}
builder.endArray();
return new BytesRestResponse(RestStatus.OK, builder);
}
示例7: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startArray(Fields.TASKS);
for (PendingClusterTask pendingClusterTask : this) {
builder.startObject();
builder.field(Fields.INSERT_ORDER, pendingClusterTask.getInsertOrder());
builder.field(Fields.PRIORITY, pendingClusterTask.getPriority());
builder.field(Fields.SOURCE, pendingClusterTask.getSource());
builder.field(Fields.EXECUTING, pendingClusterTask.isExecuting());
builder.field(Fields.TIME_IN_QUEUE_MILLIS, pendingClusterTask.getTimeInQueueInMillis());
builder.field(Fields.TIME_IN_QUEUE, pendingClusterTask.getTimeInQueue());
builder.endObject();
}
builder.endArray();
return builder;
}
示例8: testHighlightingWithWildcardName
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
public void testHighlightingWithWildcardName() throws IOException {
// test the kibana case with * as fieldname that will try highlight all fields including meta fields
XContentBuilder mappings = jsonBuilder();
mappings.startObject();
mappings.startObject("type")
.startObject("properties")
.startObject("text")
.field("type", "text")
.field("analyzer", "keyword")
.field("index_options", "offsets")
.field("term_vector", "with_positions_offsets")
.endObject()
.endObject()
.endObject();
mappings.endObject();
assertAcked(prepareCreate("test")
.addMapping("type", mappings));
client().prepareIndex("test", "type", "1")
.setSource(jsonBuilder().startObject().field("text", "text").endObject())
.get();
refresh();
for (String type : ALL_TYPES) {
SearchResponse search = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("text", "text")))
.highlighter(new HighlightBuilder().field(new Field("*").highlighterType(type))).get();
assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
}
}
示例9: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(MovAvgPipelineAggregationBuilder.MODEL.getPreferredName(), NAME);
builder.startObject(MovAvgPipelineAggregationBuilder.SETTINGS.getPreferredName());
builder.field("alpha", alpha);
builder.endObject();
return builder;
}
示例10: toRestRequest
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
private RestRequest toRestRequest(ClusterRerouteRequest original) throws IOException {
Map<String, String> params = new HashMap<>();
XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));
boolean hasBody = false;
if (randomBoolean()) {
builder.prettyPrint();
}
builder.startObject();
if (randomBoolean()) {
params.put("dry_run", Boolean.toString(original.dryRun()));
} else {
hasBody = true;
builder.field("dry_run", original.dryRun());
}
params.put("explain", Boolean.toString(original.explain()));
if (false == original.timeout().equals(AcknowledgedRequest.DEFAULT_ACK_TIMEOUT) || randomBoolean()) {
params.put("timeout", original.timeout().toString());
}
if (original.isRetryFailed() || randomBoolean()) {
params.put("retry_failed", Boolean.toString(original.isRetryFailed()));
}
if (false == original.masterNodeTimeout().equals(MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT) || randomBoolean()) {
params.put("master_timeout", original.masterNodeTimeout().toString());
}
if (original.getCommands() != null) {
hasBody = true;
original.getCommands().toXContent(builder, ToXContent.EMPTY_PARAMS);
}
builder.endObject();
FakeRestRequest.Builder requestBuilder = new FakeRestRequest.Builder(xContentRegistry());
requestBuilder.withParams(params);
if (hasBody) {
requestBuilder.withContent(builder.bytes(), builder.contentType());
}
return requestBuilder.build();
}
示例11: toString
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return builder.string();
} catch (IOException e) {
return "{ \"error\" : \"" + e.getMessage() + "\"}";
}
}
示例12: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(simpleName());
builder.field("type", mapperName);
multiFields.toXContent(builder, params);
builder.endObject();
return builder;
}
示例13: toXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.THREAD_POOL);
for (ThreadPool.Info info : infos) {
info.toXContent(builder, params);
}
builder.endObject();
return builder;
}
示例14: doXContent
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
@Override
public void doXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(getName());
if (seed != null) {
builder.field("seed", seed);
}
builder.endObject();
}
示例15: DecayFunctionBuilder
import org.elasticsearch.common.xcontent.XContentBuilder; //导入方法依赖的package包/类
/**
* Convenience constructor that converts its parameters into json to parse on the data nodes.
*/
protected DecayFunctionBuilder(String fieldName, Object origin, Object scale, Object offset, double decay) {
if (fieldName == null) {
throw new IllegalArgumentException("decay function: field name must not be null");
}
if (scale == null) {
throw new IllegalArgumentException("decay function: scale must not be null");
}
if (decay <= 0 || decay >= 1.0) {
throw new IllegalStateException("decay function: decay must be in range 0..1!");
}
this.fieldName = fieldName;
try {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
if (origin != null) {
builder.field(ORIGIN, origin);
}
builder.field(SCALE, scale);
if (offset != null) {
builder.field(OFFSET, offset);
}
builder.field(DECAY, decay);
builder.endObject();
this.functionBytes = builder.bytes();
} catch (IOException e) {
throw new IllegalArgumentException("unable to build inner function object",e);
}
}