caio.co/de/cantine

Integrate QueryParser changes into cantine

Not done, the default behaviour is changed, but I want to bring this
branch back to master for some tests.
Id
a09f5a3ee87d31ca1b9ef419c3d8c525d169a6ba
Author
Caio
Commit time
2020-03-09T13:26:50+01:00

Modified cantine/src/main.rs

@@ -154,7 +154,7
let mut subqueries: Vec<(Occur, Box<dyn Query>)> = Vec::new();

if let Some(fulltext) = &query.fulltext {
- if let Some(parsed) = self.query_parser.parse(fulltext.as_str())? {
+ if let Some(parsed) = self.query_parser.parse(fulltext.as_str()) {
subqueries.push((Occur::Must, parsed));
}
}
@@ -218,11 +218,7

let index = Index::open_in_dir(&index_path)?;
let recipe_index = RecipeIndex::try_from(&index.schema())?;
- let query_parser = QueryParser::new(
- recipe_index.fulltext,
- index.tokenizer_for_field(recipe_index.fulltext)?,
- true,
- );
+ let query_parser = QueryParser::new(&index, vec![recipe_index.fulltext])?;

let reader = index.reader()?;
let search_state = Arc::new(SearchState {

Modified cantine/tests/index_integration.rs

@@ -295,13 +295,9
let reader = GLOBAL.index.reader()?;
let searcher = reader.searcher();

- let parser = QueryParser::new(
- GLOBAL.cantine.fulltext,
- GLOBAL.index.tokenizer_for_field(GLOBAL.cantine.fulltext)?,
- true,
- );
+ let parser = QueryParser::new(&GLOBAL.index, vec![GLOBAL.cantine.fulltext])?;

- let query = parser.parse("potato cheese")?.unwrap();
+ let query = parser.parse("+potato +cheese").unwrap();

let (_total, found_ids, _next) =
GLOBAL