Skip to content

Commit

Permalink
cleanup handling for full text searches
Browse files Browse the repository at this point in the history
  • Loading branch information
hry-gh committed Nov 13, 2024
1 parent 53874ed commit 188d920
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tools/od_ref_bot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,18 @@ fn get_page<'a>(query: &'a String, data: &'a Data) -> Option<&'a str> {
let searcher = data.reader.searcher();
let query_parser = QueryParser::for_index(&data.index, data.default_fields.clone());

match query_parser.parse_query(&query) {
Ok(query) => match searcher.search(&query, &TopDocs::with_limit(1)) {
Ok(res) => {
let doc: TantivyDocument = searcher.doc(res.first().unwrap().1).unwrap();

for field in doc.iter_fields_and_values() {
if let Some(path) = data.path_to_text.get_key_value(field.1.as_str().unwrap()) {
return Some(*path.0);
}
if let Ok(query) = query_parser.parse_query(query) { if let Ok(res) = searcher.search(&query, &TopDocs::with_limit(1)) {
if let Some(doc_tuple) = res.first() {
let doc: TantivyDocument = searcher.doc(doc_tuple.1).unwrap();

for field in doc.iter_fields_and_values() {
if let Some(path) = data.path_to_text.get_key_value(field.1.as_str().unwrap()) {
return Some(*path.0);
}
}
Err(_) => (),
},
Err(_) => (),
};
}

} };

for thing in data.path_to_text.iter() {
if thing.0.contains(&path_find) {
Expand Down

0 comments on commit 188d920

Please sign in to comment.