lowercase before index
This commit is contained in:
@@ -14,7 +14,7 @@ use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use sha2::{Digest, Sha256};
|
||||
use tracing::{error, info, warn};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::folders::gather_descendant_folder_ids;
|
||||
@@ -395,6 +395,7 @@ pub async fn list_documents(
|
||||
let mut quickwit_order: Option<Vec<Uuid>> = None;
|
||||
|
||||
if let Some(query_str) = search_text.as_ref() {
|
||||
debug!(query = %query_str, "performing quickwit document search");
|
||||
let endpoint = state
|
||||
.config
|
||||
.quickwit_endpoint
|
||||
@@ -1945,8 +1946,14 @@ pub(crate) fn to_iso(dt: NaiveDateTime) -> String {
|
||||
|
||||
async fn quickwit_search(endpoint: &str, index: &str, query: &str) -> anyhow::Result<Vec<Uuid>> {
|
||||
let quickwit_query = match build_quickwit_query(query) {
|
||||
Some(q) => q,
|
||||
None => return Ok(vec![]),
|
||||
Some(q) => {
|
||||
debug!(%query, quickwit_query = %q, "built quickwit search query");
|
||||
q
|
||||
}
|
||||
None => {
|
||||
debug!(%query, "quickwit search skipped because query produced no tokens");
|
||||
return Ok(vec![]);
|
||||
}
|
||||
};
|
||||
|
||||
let client = Client::new();
|
||||
@@ -1957,20 +1964,25 @@ async fn quickwit_search(endpoint: &str, index: &str, query: &str) -> anyhow::Re
|
||||
"max_hits": QUICKWIT_MAX_HITS,
|
||||
});
|
||||
|
||||
debug!(%url, payload = %payload, "sending quickwit search request");
|
||||
let response = client.post(url).json(&payload).send().await?;
|
||||
if !response.status().is_success() {
|
||||
let status = response.status();
|
||||
let body = response.text().await.unwrap_or_default();
|
||||
error!(%status, body = %body, "quickwit search request failed");
|
||||
return Err(anyhow::anyhow!(
|
||||
"quickwit search failed with status {status}: {body}"
|
||||
));
|
||||
}
|
||||
|
||||
let data: QuickwitSearchResponse = response.json().await?;
|
||||
debug!("quickwit search response parsed successfully");
|
||||
let QuickwitSearchResponse { hits } = data;
|
||||
let mut seen = HashSet::new();
|
||||
let mut doc_ids = Vec::new();
|
||||
let total_hits = hits.len();
|
||||
|
||||
for hit in data.hits {
|
||||
for hit in hits {
|
||||
if let Some(doc_id) = extract_document_id(&hit) {
|
||||
if seen.insert(doc_id) {
|
||||
doc_ids.push(doc_id);
|
||||
@@ -1978,6 +1990,7 @@ async fn quickwit_search(endpoint: &str, index: &str, query: &str) -> anyhow::Re
|
||||
}
|
||||
}
|
||||
|
||||
debug!(total_hits = total_hits, unique_ids = doc_ids.len(), "quickwit search completed");
|
||||
Ok(doc_ids)
|
||||
}
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ impl JobHandler for IndexDocumentTextJob {
|
||||
let payload = json!({
|
||||
"document_id": context.document.id,
|
||||
"version_id": context.version.id,
|
||||
"title": context.document.title,
|
||||
"text": text,
|
||||
"title": context.document.title.to_lowercase(),
|
||||
"text": text.to_lowercase()
|
||||
});
|
||||
|
||||
let body = serde_json::to_string(&payload).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user