Adding Value::From<PretokenizedText> (#697)

This commit is contained in:
Paul Masurel
2019-11-10 14:39:44 +09:00
committed by GitHub
parent 88fd7f091a
commit fb3d6fa332
2 changed files with 7 additions and 3 deletions

View File

@@ -67,9 +67,7 @@ fn main() -> tantivy::Result<()> {
// Now lets create a document and add our `PreTokenizedString` using
// `add_pre_tokenized_text` method of `Document`
let mut old_man_doc = Document::default();
old_man_doc.add_pre_tokenized_text(title, &title_tok);
old_man_doc.add_pre_tokenized_text(body, &body_tok);
let old_man_doc = doc!(title => title_tok, body => body_tok);
// ... now let's just add it to the IndexWriter
index_writer.add_document(old_man_doc);

View File

@@ -233,6 +233,12 @@ impl From<Vec<u8>> for Value {
}
}
impl From<PreTokenizedString> for Value {
fn from(pretokenized_string: PreTokenizedString) -> Value {
Value::PreTokStr(pretokenized_string)
}
}
mod binary_serialize {
use super::Value;
use crate::common::{f64_to_u64, u64_to_f64, BinarySerializable};