@@ -128,7 +128,25 @@ fn value_to_string(value: &Value) -> String {
128
128
///
129
129
/// Example:
130
130
/// >>> doc = tantivy.Document(title="The Old Man and the Sea", body="...")
131
-
131
+ ///
132
+ /// For numeric fields, the [`Document`] constructor does not have any
133
+ /// information about the type and will try to guess the type.
134
+ /// Therefore, it is recommended to use the [`Document::from_dict()`],
135
+ /// [`Document::extract()`], or `Document::add_*()` functions to provide
136
+ /// explicit type information.
137
+ ///
138
+ /// Example:
139
+ /// >>> schema = (
140
+ /// SchemaBuilder()
141
+ /// .add_unsigned_field("unsigned")
142
+ /// .add_integer_field("signed")
143
+ /// .add_float_field("float")
144
+ /// .build()
145
+ /// )
146
+ /// >>> doc = tantivy.Document.from_dict(
147
+ /// {"unsigned": 1000, "signed": -5, "float": 0.4},
148
+ /// schema,
149
+ /// )
132
150
#[ pyclass]
133
151
#[ derive( Default ) ]
134
152
pub ( crate ) struct Document {
@@ -330,6 +348,11 @@ impl Document {
330
348
331
349
#[ pymethods]
332
350
impl Document {
351
+ /// Creates a new document with optional fields from `**kwargs`.
352
+ ///
353
+ /// Note that the types of numeric fields are unknown here. To
354
+ /// provide explicit type information, use the [from_dict()],
355
+ /// [extend()], or `add_<type>()` functions.
333
356
#[ new]
334
357
#[ pyo3( signature = ( * * kwargs) ) ]
335
358
fn new ( kwargs : Option < & PyDict > ) -> PyResult < Self > {
0 commit comments