Skip to content

Commit 188d920

Browse files
committed
cleanup handling for full text searches
1 parent 53874ed commit 188d920

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

tools/od_ref_bot/src/main.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,18 @@ fn get_page<'a>(query: &'a String, data: &'a Data) -> Option<&'a str> {
106106
let searcher = data.reader.searcher();
107107
let query_parser = QueryParser::for_index(&data.index, data.default_fields.clone());
108108

109-
match query_parser.parse_query(&query) {
110-
Ok(query) => match searcher.search(&query, &TopDocs::with_limit(1)) {
111-
Ok(res) => {
112-
let doc: TantivyDocument = searcher.doc(res.first().unwrap().1).unwrap();
113-
114-
for field in doc.iter_fields_and_values() {
115-
if let Some(path) = data.path_to_text.get_key_value(field.1.as_str().unwrap()) {
116-
return Some(*path.0);
117-
}
109+
if let Ok(query) = query_parser.parse_query(query) { if let Ok(res) = searcher.search(&query, &TopDocs::with_limit(1)) {
110+
if let Some(doc_tuple) = res.first() {
111+
let doc: TantivyDocument = searcher.doc(doc_tuple.1).unwrap();
112+
113+
for field in doc.iter_fields_and_values() {
114+
if let Some(path) = data.path_to_text.get_key_value(field.1.as_str().unwrap()) {
115+
return Some(*path.0);
118116
}
119117
}
120-
Err(_) => (),
121-
},
122-
Err(_) => (),
123-
};
118+
}
119+
120+
} };
124121

125122
for thing in data.path_to_text.iter() {
126123
if thing.0.contains(&path_find) {

0 commit comments

Comments
 (0)