feat(integrations): implement query expansion for semantic search #44
@ -5,6 +5,15 @@ const MAX_EXPANDED_QUERIES: usize = 3;
|
|||||||
|
|
||||||
fn escape_wiql(s: &str) -> String {
|
fn escape_wiql(s: &str) -> String {
|
||||||
s.replace('\'', "''")
|
s.replace('\'', "''")
|
||||||
|
.replace('"', "\\\"")
|
||||||
|
.replace('\\', "\\\\")
|
||||||
|
.replace('(', "\\(")
|
||||||
|
.replace(')', "\\)")
|
||||||
|
.replace('~', "\\~")
|
||||||
|
.replace('*', "\\*")
|
||||||
|
.replace('?', "\\?")
|
||||||
|
.replace(';', "\\;")
|
||||||
|
.replace('=', "\\=")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Search Azure DevOps Wiki for content matching the query
|
/// Search Azure DevOps Wiki for content matching the query
|
||||||
|
|||||||
@ -57,7 +57,10 @@ pub async fn search_confluence(
|
|||||||
urlencoding::encode(&safe_query)
|
urlencoding::encode(&safe_query)
|
||||||
);
|
);
|
||||||
|
|
||||||
tracing::info!("Searching Confluence with expanded query: {}", search_url);
|
tracing::info!(
|
||||||
|
"Searching Confluence with expanded query: {}",
|
||||||
|
expanded_query
|
||||||
|
);
|
||||||
|
|
||||||
let resp = client
|
let resp = client
|
||||||
.get(&search_url)
|
.get(&search_url)
|
||||||
@ -80,7 +83,7 @@ pub async fn search_confluence(
|
|||||||
.map_err(|e| format!("Failed to parse Confluence search response: {e}"))?;
|
.map_err(|e| format!("Failed to parse Confluence search response: {e}"))?;
|
||||||
|
|
||||||
if let Some(results_array) = json["results"].as_array() {
|
if let Some(results_array) = json["results"].as_array() {
|
||||||
for item in results_array.iter().take(3) {
|
for item in results_array.iter().take(MAX_EXPANDED_QUERIES) {
|
||||||
let title = item["title"].as_str().unwrap_or("Untitled").to_string();
|
let title = item["title"].as_str().unwrap_or("Untitled").to_string();
|
||||||
|
|
||||||
let id = item["content"]["id"].as_str();
|
let id = item["content"]["id"].as_str();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user