org.elasticsearch.common.xcontent.XContentBuilder.value()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中org.elasticsearch.common.xcontent.XContentBuilder.value()方法的一些代码示例,展示了XContentBuilder.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XContentBuilder.value()方法的具体详情如下:
包路径:org.elasticsearch.common.xcontent.XContentBuilder
类名称:XContentBuilder
方法名:value

XContentBuilder.value介绍

[英]Writes the binary content of the given BytesRef Use org.elasticsearch.common.xcontent.XContentParser#binaryValue() to read the value back
[中]写入给定BytesRef Use org的二进制内容。弹性搜索。常见的非常重要。XContentParser#binaryValue()读回值

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

private static void buildLikeField(XContentBuilder builder, String fieldName, String[] texts, Item[] items) throws IOException {
  if (texts.length > 0 || items.length > 0) {
    builder.startArray(fieldName);
    for (String text : texts) {
      builder.value(text);
    }
    for (Item item : items) {
      builder.value(item);
    }
    builder.endArray();
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private static void headerToXContent(XContentBuilder builder, String key, List<String> values) throws IOException {
  if (values != null && values.isEmpty() == false) {
    if (values.size() == 1) {
      builder.field(key, values.get(0));
    } else {
      builder.startArray(key);
      for (String value : values) {
        builder.value(value);
      }
      builder.endArray();
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject(Fields.MERGES);
  builder.field(Fields.CURRENT, current);
  builder.field(Fields.CURRENT_DOCS, currentNumDocs);
  builder.humanReadableField(Fields.CURRENT_SIZE_IN_BYTES, Fields.CURRENT_SIZE, getCurrentSize());
  builder.field(Fields.TOTAL, total);
  builder.humanReadableField(Fields.TOTAL_TIME_IN_MILLIS, Fields.TOTAL_TIME, getTotalTime());
  builder.field(Fields.TOTAL_DOCS, totalNumDocs);
  builder.humanReadableField(Fields.TOTAL_SIZE_IN_BYTES, Fields.TOTAL_SIZE, getTotalSize());
  builder.humanReadableField(Fields.TOTAL_STOPPED_TIME_IN_MILLIS, Fields.TOTAL_STOPPED_TIME, getTotalStoppedTime());
  builder.humanReadableField(Fields.TOTAL_THROTTLED_TIME_IN_MILLIS, Fields.TOTAL_THROTTLED_TIME, getTotalThrottledTime());
  if (builder.humanReadable() && totalBytesPerSecAutoThrottle != -1) {
    builder.field(Fields.TOTAL_THROTTLE_BYTES_PER_SEC).value(new ByteSizeValue(totalBytesPerSecAutoThrottle).toString());
  }
  builder.field(Fields.TOTAL_THROTTLE_BYTES_PER_SEC_IN_BYTES, totalBytesPerSecAutoThrottle);
  builder.endObject();
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public void toXContent(String preferredName, XContentBuilder builder) throws IOException {
  if (fetchFields == false) {
    builder.field(preferredName, _NONE_);
  }
  if (fieldNames != null) {
    if (fieldNames.size() == 1) {
      builder.field(preferredName, fieldNames.get(0));
    } else {
      builder.startArray(preferredName);
      for (String fieldName : fieldNames) {
        builder.value(fieldName);
      }
      builder.endArray();
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

protected static XContentBuilder toXContent(XContentBuilder builder, Coordinate coordinate) throws IOException {
  builder.startArray().value(coordinate.x).value(coordinate.y);
  if (Double.isNaN(coordinate.z) == false) {
    builder.value(coordinate.z);
  }
  return builder.endArray();
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

public XContentBuilder toXContent(XContentBuilder builder, Params params, boolean includeFieldName) throws IOException {
  if (includeFieldName) {
    builder.field(X_FIELD_NAME, fuzziness);
  } else {
    builder.value(fuzziness);
  }
  return builder;
}

代码示例来源:origin: komoot/photon

private static void writeExtent(XContentBuilder builder, Envelope bbox) throws IOException {
  if (bbox == null) return;
  if (bbox.getArea() == 0.) return;
  // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-geo-shape-type.html#_envelope
  builder.startObject("extent");
  builder.field("type", "envelope");
  builder.startArray("coordinates");
  builder.startArray().value(bbox.getMinX()).value(bbox.getMaxY()).endArray();
  builder.startArray().value(bbox.getMaxX()).value(bbox.getMinY()).endArray();
  builder.endArray();
  builder.endObject();
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  if (formattedSortValues.length > 0) {
    builder.startArray(Fields.SORT);
    for (Object sortValue : formattedSortValues) {
      builder.value(sortValue);
    }
    builder.endArray();
  }
  return builder;
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Writes the binary content of the given {@link BytesReference}.
 *
 * Use {@link org.elasticsearch.common.xcontent.XContentParser#binaryValue()} to read the value back
 */
public XContentBuilder field(String name, BytesReference value) throws IOException {
  return field(name).value(value);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.field(name);
  if (fragments == null) {
    builder.nullValue();
  } else {
    builder.startArray();
    for (Text fragment : fragments) {
      builder.value(fragment);
    }
    builder.endArray();
  }
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startArray(name);
  for (Object value : values) {
    // this call doesn't really need to support writing any kind of object.
    // Stored fields values are converted using MappedFieldType#valueForDisplay.
    // As a result they can either be Strings, Numbers, or Booleans, that's
    // all.
    builder.value(value);
  }
  builder.endArray();
  return builder;
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder toXContent(XContentBuilder builder, Params params, boolean includeFieldName) throws IOException {
  if (includeFieldName) {
    builder.field(X_FIELD_NAME, fuzziness);
  } else {
    builder.value(fuzziness);
  }
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@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;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  if (!copyToFields.isEmpty()) {
    builder.startArray("copy_to");
    for (String field : copyToFields) {
      builder.value(field);
    }
    builder.endArray();
  }
  return builder;
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder field(XContentBuilderString name, Map<String, Object> value) throws IOException {
  field(name);
  value(value);
  return this;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.field(Fields.SNAPSHOT, name);
  builder.startArray(Fields.INDICES);
  for (String index : indices) {
    builder.value(index);
  }
  builder.endArray();
  builder.startObject(Fields.SHARDS);
  builder.field(Fields.TOTAL, totalShards);
  builder.field(Fields.FAILED, failedShards());
  builder.field(Fields.SUCCESSFUL, successfulShards);
  builder.endObject();
  builder.endObject();
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.startArray("scroll_id");
  for (String scrollId : scrollIds) {
    builder.value(scrollId);
  }
  builder.endArray();
  builder.endObject();
  return builder;
}

代码示例来源:origin: harbby/presto-connectors

public XContentBuilder field(String name, Map<String, Object> value) throws IOException {
  field(name);
  value(value);
  return this;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject(clusterAlias);
  {
    builder.startArray("seeds");
    for (String addr : seedNodes) {
      builder.value(addr);
    }
    builder.endArray();
    builder.startArray("http_addresses");
    for (TransportAddress addr : httpAddresses) {
      builder.value(addr.toString());
    }
    builder.endArray();
    builder.field("connected", numNodesConnected > 0);
    builder.field("num_nodes_connected", numNodesConnected);
    builder.field("max_connections_per_cluster", connectionsPerCluster);
    builder.field("initial_connect_timeout", initialConnectionTimeout);
    builder.field("skip_unavailable", skipUnavailable);
  }
  builder.endObject();
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
  public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    if (children == null) {
      builder.startArray().value(coordinate.x).value(coordinate.y).endArray();
    } else {
      builder.startArray();
      for (CoordinateNode child : children) {
        child.toXContent(builder, params);
      }
      builder.endArray();
    }
    return builder;
  }
}

相关文章

微信公众号

最新文章

更多