From 82d25b83972dfc2faef6a8d25f6c1af07b314856 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Thu, 13 Sep 2018 12:39:42 +0900 Subject: [PATCH] Fixing snippet example --- examples/snippet.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/snippet.rs b/examples/snippet.rs index bc31a3e38..5e1fa27d1 100644 --- a/examples/snippet.rs +++ b/examples/snippet.rs @@ -24,7 +24,8 @@ fn main() -> tantivy::Result<()> { // # Defining the schema let mut schema_builder = SchemaBuilder::default(); - schema_builder.add_text_field("body", TEXT); + let title = schema_builder.add_text_field("title", TEXT | STORED); + let body = schema_builder.add_text_field("body", TEXT | STORED); let schema = schema_builder.build(); // # Indexing documents @@ -32,9 +33,6 @@ fn main() -> tantivy::Result<()> { let mut index_writer = index.writer(50_000_000)?; - let title = schema.get_field("title").unwrap(); - let body = schema.get_field("body").unwrap(); - // we'll only need one doc for this example. index_writer.add_document(doc!( title => "Of Mice and Men", @@ -68,6 +66,6 @@ fn main() -> tantivy::Result<()> { println!("title: {}", doc.get_first(title).unwrap().text().unwrap()); println!("snippet: {}", snippet.to_html()); } - + Ok(()) }