Describe the bug
I created a blank schema with the following types:
pub fn schema() -> TantivySchema {
let mut schema_builder = TantivySchema::builder();
SchemaField::iter().for_each(|field| {
let opts = DateOptions::from(INDEXED)
.set_stored()
.set_fast()
.set_precision(DateTimePrecision::Seconds);
match field.r#type() {
FieldTypes::Text => schema_builder.add_text_field(&field.name(), TEXT | STORED),
FieldTypes::Integer => schema_builder.add_u64_field(&field.name(), FAST | STORED),
FieldTypes::Float => schema_builder.add_f64_field(&field.name(), FAST | STORED),
FieldTypes::Boolean => schema_builder.add_bool_field(&field.name(), FAST | STORED),
FieldTypes::Date => schema_builder.add_date_field(&field.name(), opts),
FieldTypes::Json => schema_builder.add_json_field(&field.name(), TEXT | STORED),
};
});
schema_builder.build()
}
From there the types that belong to my schema are actually the id which is of type u64 and created_at which is of type DateTime<Utc> from chrono. However, to test the validity of my program I'm using tantivy::DateTime::default() as follows:
let body: Map<String, Value> = serde_json::from_value(json).map_err(|e| {
Error::SchemaError(anyhow::anyhow!("Error deserializing document: {:?}", e))
})?;
let mut doc = Document::default();
doc.add_u64(id_field, *id);
doc.add_json_object(body_field, body);
doc.add_date(created_at_field, TantivyDateTime::default());
doc.add_date(updated_at_field, TantivyDateTime::default());
acc.push(doc);
When trying to query all I get is:
Error parsing term: DateFormatError(ParseFromDescription(InvalidComponent(\"year\")))"
Even for simple queries like a number or a letter. I tried removing fields from the searcher but no luck.
To query by date without issue.
Which version of tantivy are you using?
Let me know if this is enough, if not I can try to be more specific or even look for a minimum set for reproduction.
Describe the bug
I created a blank schema with the following types:
From there the types that belong to my schema are actually the
idwhich is of typeu64andcreated_atwhich is of typeDateTime<Utc>from chrono. However, to test the validity of my program I'm usingtantivy::DateTime::default()as follows:When trying to query all I get is:
Error parsing term: DateFormatError(ParseFromDescription(InvalidComponent(\"year\")))"Even for simple queries like a number or a letter. I tried removing fields from the
searcherbut no luck.To query by date without issue.
Which version of tantivy are you using?
Let me know if this is enough, if not I can try to be more specific or even look for a minimum set for reproduction.