コード例 #1
0
 public Builder(IndexTemplateMetaData indexTemplateMetaData) {
   this(indexTemplateMetaData.name());
   order(indexTemplateMetaData.order());
   template(indexTemplateMetaData.template());
   settings(indexTemplateMetaData.settings());
   mappings.putAll(indexTemplateMetaData.mappings());
 }
コード例 #2
0
    public static void toXContent(
        IndexTemplateMetaData indexTemplateMetaData,
        XContentBuilder builder,
        ToXContent.Params params)
        throws IOException {
      builder.startObject(indexTemplateMetaData.name(), XContentBuilder.FieldCaseConversion.NONE);

      builder.field("order", indexTemplateMetaData.order());
      builder.field("template", indexTemplateMetaData.template());

      builder.startObject("settings");
      for (Map.Entry<String, String> entry :
          indexTemplateMetaData.settings().getAsMap().entrySet()) {
        builder.field(entry.getKey(), entry.getValue());
      }
      builder.endObject();

      builder.startArray("mappings");
      for (Map.Entry<String, CompressedString> entry :
          indexTemplateMetaData.mappings().entrySet()) {
        byte[] data = entry.getValue().uncompressed();
        XContentParser parser = XContentFactory.xContent(data).createParser(data);
        Map<String, Object> mapping = parser.map();
        parser.close();
        builder.map(mapping);
      }
      builder.endArray();

      builder.endObject();
    }
コード例 #3
0
 public static void writeTo(IndexTemplateMetaData indexTemplateMetaData, StreamOutput out)
     throws IOException {
   out.writeUTF(indexTemplateMetaData.name());
   out.writeInt(indexTemplateMetaData.order());
   out.writeUTF(indexTemplateMetaData.template());
   ImmutableSettings.writeSettingsToStream(indexTemplateMetaData.settings(), out);
   out.writeVInt(indexTemplateMetaData.mappings().size());
   for (Map.Entry<String, CompressedString> entry :
       indexTemplateMetaData.mappings().entrySet()) {
     out.writeUTF(entry.getKey());
     entry.getValue().writeTo(out);
   }
 }
コード例 #4
0
 public Builder put(IndexTemplateMetaData template) {
   templates.put(template.name(), template);
   return this;
 }