public static void WriteIndexDefinition(this BlittableJsonTextWriter writer, JsonOperationContext context, IndexDefinition indexDefinition, bool removeAnalyzers = false) { writer.WriteStartObject(); writer.WritePropertyName(nameof(indexDefinition.Name)); writer.WriteString(indexDefinition.Name); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Etag)); writer.WriteInteger(indexDefinition.Etag); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Type)); writer.WriteString(indexDefinition.Type.ToString()); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.LockMode)); if (indexDefinition.LockMode.HasValue) { writer.WriteString(indexDefinition.LockMode.ToString()); } else { writer.WriteNull(); } writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Priority)); if (indexDefinition.Priority.HasValue) { writer.WriteString(indexDefinition.Priority.ToString()); } else { writer.WriteNull(); } writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.OutputReduceToCollection)); writer.WriteString(indexDefinition.OutputReduceToCollection); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Configuration)); writer.WriteStartObject(); var isFirstInternal = true; foreach (var kvp in indexDefinition.Configuration) { if (isFirstInternal == false) { writer.WriteComma(); } isFirstInternal = false; writer.WritePropertyName(kvp.Key); writer.WriteString(kvp.Value); } writer.WriteEndObject(); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.AdditionalSources)); writer.WriteStartObject(); isFirstInternal = true; foreach (var kvp in indexDefinition.AdditionalSources) { if (isFirstInternal == false) { writer.WriteComma(); } isFirstInternal = false; writer.WritePropertyName(kvp.Key); writer.WriteString(kvp.Value); } writer.WriteEndObject(); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.IsTestIndex)); writer.WriteBool(indexDefinition.IsTestIndex); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Reduce)); if (string.IsNullOrWhiteSpace(indexDefinition.Reduce) == false) { writer.WriteString(indexDefinition.Reduce); } else { writer.WriteNull(); } writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Maps)); writer.WriteStartArray(); isFirstInternal = true; foreach (var map in indexDefinition.Maps) { if (isFirstInternal == false) { writer.WriteComma(); } isFirstInternal = false; writer.WriteString(map); } writer.WriteEndArray(); writer.WriteComma(); writer.WritePropertyName(nameof(indexDefinition.Fields)); writer.WriteStartObject(); isFirstInternal = true; foreach (var kvp in indexDefinition.Fields) { if (isFirstInternal == false) { writer.WriteComma(); } isFirstInternal = false; writer.WritePropertyName(kvp.Key); if (kvp.Value != null) { writer.WriteIndexFieldOptions(context, kvp.Value, removeAnalyzers); } else { writer.WriteNull(); } } writer.WriteEndObject(); writer.WriteEndObject(); }