Method AddDocument
- Namespace
- TantivyDotNet
- Assembly
- TantivyDotNet.dll
AddDocument(string)
Adds a document given as a JSON object mapping field names to a value or an array of
values, for example {"title": "Of Mice and Men", "year": 1937}. A property that isn't a
schema field is an error unless the writer was created with IgnoreUnknownFields.
public void AddDocument(string json)
Parameters
jsonstring
Exceptions
- TantivyException
With InvalidArgument if the JSON is invalid, a value doesn't match its field type, or a field is unknown.
AddDocument(ReadOnlySpan<byte>)
Adds a document given as a JSON object mapping field names to a value or an array of
values, for example {"title": "Of Mice and Men", "year": 1937}. A property that isn't a
schema field is an error unless the writer was created with IgnoreUnknownFields.
public void AddDocument(ReadOnlySpan<byte> utf8Json)
Parameters
utf8JsonReadOnlySpan<byte>
Exceptions
- TantivyException
With InvalidArgument if the JSON is invalid, a value doesn't match its field type, or a field is unknown.
AddDocument<T>(T, JsonTypeInfo<T>)
Serializes document with System.Text.Json source-generated metadata and
adds it. This overload is trimming- and NativeAOT-safe. JSON property names must match the
schema's field names.
public void AddDocument<T>(T document, JsonTypeInfo<T> typeInfo)
Parameters
documentTtypeInfoJsonTypeInfo<T>
Type Parameters
T
AddDocument(object)
Serializes document (for example an anonymous object) with reflection-based
System.Text.Json and adds it. Property names must match the schema's field names exactly.
For trimmed or NativeAOT apps, use AddDocument<T>(T, JsonTypeInfo<T>) instead.
[RequiresUnreferencedCode("Reflection-based JSON serialization. Use AddDocument<T>(T, JsonTypeInfo<T>) for trimmed apps.")]
[RequiresDynamicCode("Reflection-based JSON serialization. Use AddDocument<T>(T, JsonTypeInfo<T>) for NativeAOT apps.")]
public void AddDocument(object document)
Parameters
documentobject