public BookSearchIndex(string name) : base(name) { _searchFields.ForEach(Fields.Add); Suggesters.Add(new SearchSuggester("sg", "authors", "original_title")); CorsOptions = new CorsOptions(new[] { "*" }) { MaxAgeInSeconds = 300 }; }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("name"); writer.WriteStringValue(Name); if (Fields.Any()) { writer.WritePropertyName("fields"); writer.WriteStartArray(); foreach (var item in Fields) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } else { writer.WriteNull("fields"); } if (ScoringProfiles != null && ScoringProfiles.Any()) { writer.WritePropertyName("scoringProfiles"); writer.WriteStartArray(); foreach (var item in ScoringProfiles) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (DefaultScoringProfile != null) { writer.WritePropertyName("defaultScoringProfile"); writer.WriteStringValue(DefaultScoringProfile); } if (CorsOptions != null) { writer.WritePropertyName("corsOptions"); writer.WriteObjectValue(CorsOptions); } if (Suggesters != null && Suggesters.Any()) { writer.WritePropertyName("suggesters"); writer.WriteStartArray(); foreach (var item in Suggesters) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (Analyzers != null && Analyzers.Any()) { writer.WritePropertyName("analyzers"); writer.WriteStartArray(); foreach (var item in Analyzers) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (Tokenizers != null && Tokenizers.Any()) { writer.WritePropertyName("tokenizers"); writer.WriteStartArray(); foreach (var item in Tokenizers) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (TokenFilters != null && TokenFilters.Any()) { writer.WritePropertyName("tokenFilters"); writer.WriteStartArray(); foreach (var item in TokenFilters) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (CharFilters != null && CharFilters.Any()) { writer.WritePropertyName("charFilters"); writer.WriteStartArray(); foreach (var item in CharFilters) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (EncryptionKey != null) { writer.WritePropertyName("encryptionKey"); writer.WriteObjectValue(EncryptionKey); } if (Similarity != null) { writer.WritePropertyName("similarity"); writer.WriteObjectValue(Similarity); } if (_etag != null) { writer.WritePropertyName("@odata.etag"); writer.WriteStringValue(_etag); } writer.WriteEndObject(); }