Skip to content

Commit

Permalink
fix: escape colons in term query (#159) (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Jul 11, 2024
1 parent 0d0e5af commit 5c40e30
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/server/run/hpo_terms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,14 @@ async fn handle(
query_parser.set_field_fuzzy(field_synonym, true, 1, true);
query_parser
};
let index_query = query_parser.parse_query(name).map_err(|e| {
eprintln!("{e}");
CustomError::new(anyhow::anyhow!("Error parsing query: {}", e))
})?;
let name = if name.contains(":") {

Check warning on line 298 in src/server/run/hpo_terms.rs

View workflow job for this annotation

GitHub Actions / clippy

single-character string constant used as pattern

warning: single-character string constant used as pattern --> src/server/run/hpo_terms.rs:298:37 | 298 | let name = if name.contains(":") { | ^^^ help: consider using a `char`: `':'` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern = note: `#[warn(clippy::single_char_pattern)]` on by default
format!("\"{name}\"")
} else {
name.to_string()
};
let index_query = query_parser
.parse_query(&name)
.map_err(|e| CustomError::new(anyhow::anyhow!("Error parsing query: {}", e)))?;
let top_docs = searcher
.search(
&index_query,
Expand Down

0 comments on commit 5c40e30

Please sign in to comment.