extern crate rustc_serialize;
-extern crate tantivy;
+ extern crate tantivy;
extern crate tempdir;
+#[macro_use]
+extern crate serde_json;
+
use std::path::Path;
use tempdir::TempDir;
use tantivy::Index;
@@ -108,8 +110,8 @@ be indexed”.
¶
Our first field is title.
-We want full-text search for it, and we want to be able
-to retrieve the document after the search.
+We want full-text search for it, and we also want
+to be able to retrieve the document after the search.
TEXT | STORED is some syntactic sugar to describe
that.
TEXT means the field should be tokenized and indexed,
@@ -132,9 +134,12 @@ documents that were selected during the search phase.
- Our first field is body.
-We want full-text search for it, and we want to be able
-to retrieve the body after the search.
+ Our second field is body.
+We want full-text search for it, but we do not
+need to be able to be able to retrieve it
+for our application.
+We can make our index lighter and
+by omitting STORED flag.
@@ -158,7 +163,7 @@ with our schema in the directory.
let index = try!(Index::create(index_path, schema.clone())); let index = Index::create(index_path, schema.clone())?;