Skip to content

web search done right

get_webpage only looked at the response from the shard with the quickest response. this obviously caused webpages to not be found seemingly at random, which caused summarizer to fail

Mikkel Denker88c8cbce411b
diff --git a/crates/core/src/searcher/distributed.rs b/crates/core/src/searcher/distributed.rs
index 832dafa1..fce64fcc 100644
--- a/crates/core/src/searcher/distributed.rs
+++ b/crates/core/src/searcher/distributed.rs
@@ -234,7 +234,7 @@ impl SearchClient for DistributedSearcher {
.await
.map_err(|_| Error::SearchFailed)?;
- if let Some(Some(res)) = res.into_iter().flat_map(|(_, v)| v).next() {
+ if let Some(res) = res.into_iter().flat_map(|(_, v)| v).flat_map(|v| v).next() {
Ok(Some(res))
} else {
Err(Error::WebpageNotFound.into())
@@ -280,7 +280,7 @@ impl SearchClient for DistributedSearcher {
.await
.map_err(|_| Error::SearchFailed)?
.pop()
- .unwrap())
+ .flatten())
}
async fn search_entity(&self, query: &str) -> Option<EntityMatch> {