From 16e7c876b6af2587ea6932db25314daea9b74d2e Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sun, 21 Feb 2016 14:10:51 +0900 Subject: [PATCH] blop --- Cargo.toml | 2 +- src/main.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a48a09..c84bba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,5 @@ authors = ["Paul Masurel "] [dependencies] -tantivy = { path = "/home/pmasurel/github/tantivy" } +tantivy = { path = "../tantivy" } time = "0.1.34" diff --git a/src/main.rs b/src/main.rs index 725ade3..158c907 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use std::convert::From; use std::path::PathBuf; use tantivy::core::query; use tantivy::core::query::parse_query; -use tantivy::core::analyzer::SimpleTokenizer; +use tantivy::core::analyzer::*; use std::borrow::Borrow; use std::io::BufRead; use std::fs; @@ -47,7 +47,7 @@ fn main() { let url_field = schema.add_field("url", &str_fieldtype); let title_field = schema.add_field("title", &text_fieldtype); let body_field = schema.add_field("body", &text_fieldtype); - let mut directory = Directory::open(&PathBuf::from("/media/ssd/wikiindex")).unwrap(); + let mut directory = Directory::open(&PathBuf::from("/data/wiki-index/")).unwrap(); directory.set_schema(&schema); let searcher = Searcher::for_directory(directory); let tokenizer = SimpleTokenizer::new(); @@ -63,8 +63,13 @@ fn main() { let mut terms: Vec = Vec::new(); let mut token_it = tokenizer.tokenize(&input); let mut term_buffer = String::new(); - while token_it.read_one(&mut term_buffer) { - terms.push(Term::from_field_text(&body_field, &term_buffer)); + loop { + match token_it.next() { + Some(token) => { + terms.push(Term::from_field_text(&body_field, &token)); + } + None => { break; } + } } // let terms = keywords.iter().map(|s| Term::from_field_text(&body_field, &s)); println!("Input: {:?}", input);