From b12a61928dab37ebcab84b04337b5a7b8b8fd63a Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Mon, 6 May 2024 14:11:54 +0200 Subject: [PATCH] did this solve the compilation errors --- .../src/search/search_executor/query.rs | 25 +++++++++++++++---- server/main-api/src/setup/meilisearch.rs | 9 ++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/server/main-api/src/search/search_executor/query.rs b/server/main-api/src/search/search_executor/query.rs index 4249848af..95fb277ce 100644 --- a/server/main-api/src/search/search_executor/query.rs +++ b/server/main-api/src/search/search_executor/query.rs @@ -4,8 +4,8 @@ use meilisearch_sdk::indexes::Index; use meilisearch_sdk::search::{MultiSearchResponse, SearchQuery, Selectors}; use serde::Deserialize; -use crate::search::SanitisedSearchQueryArgs; use crate::search::search_executor::parser::{Filter, ParsedQuery, TextToken}; +use crate::search::SanitisedSearchQueryArgs; #[derive(Deserialize, Default, Clone, Debug)] #[allow(dead_code)] @@ -129,7 +129,10 @@ impl GeoEntryQuery { .join(" ") } - fn common_query<'b: 'a, 'a>(&'b self, entries: &'a Index) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { + fn common_query<'b: 'a, 'a>( + &'b self, + entries: &'a Index, + ) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { SearchQuery::new(entries) .with_facets(Selectors::Some(&["facet"])) .with_highlight_pre_tag(&self.highlighting.0) @@ -138,7 +141,11 @@ impl GeoEntryQuery { .build() } - fn merged_query<'a>(&'a self, entries: &'a Index, query: &'a str) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { + fn merged_query<'a>( + &'a self, + entries: &'a Index, + query: &'a str, + ) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { let mut s = self .common_query(entries) .with_query(query) @@ -150,7 +157,11 @@ impl GeoEntryQuery { s } - fn buildings_query<'a>(&'a self, entries: &'a Index, query: &'a str) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { + fn buildings_query<'a>( + &'a self, + entries: &'a Index, + query: &'a str, + ) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { self.common_query(entries) .with_query(query) .with_limit(2 * self.args.limit_buildings) // we might do reordering later @@ -158,7 +169,11 @@ impl GeoEntryQuery { .build() } - fn rooms_query<'a>(&'a self, entries: &'a Index, query: &'a str) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { + fn rooms_query<'a>( + &'a self, + entries: &'a Index, + query: &'a str, + ) -> SearchQuery<'a, meilisearch_sdk::DefaultHttpClient> { self.common_query(entries) .with_query(query) .with_limit(self.args.limit_rooms) diff --git a/server/main-api/src/setup/meilisearch.rs b/server/main-api/src/setup/meilisearch.rs index 621f1cccf..beb1aae1e 100644 --- a/server/main-api/src/setup/meilisearch.rs +++ b/server/main-api/src/setup/meilisearch.rs @@ -1,10 +1,11 @@ +use std::collections::HashMap; +use std::time::Duration; + use log::{error, info}; +use meilisearch_sdk::client::Client; use meilisearch_sdk::settings::Settings; use meilisearch_sdk::tasks::Task; -use meilisearch_sdk::Client; use serde_json::Value; -use std::collections::HashMap; -use std::time::Duration; const TIMEOUT: Option = Some(Duration::from_secs(20)); const POLLING_RATE: Option = Some(Duration::from_millis(50)); @@ -48,7 +49,7 @@ pub(crate) async fn setup_meilisearch() -> Result<(), crate::BoxedError> { let start = std::time::Instant::now(); let ms_url = std::env::var("MIELI_URL").unwrap_or_else(|_| "http://localhost:7700".to_string()); info!("connecting to Meilisearch at {ms_url}", ms_url = ms_url); - let client = Client::new(ms_url, std::env::var("MEILI_MASTER_KEY").ok()); + let client = Client::new(ms_url, std::env::var("MEILI_MASTER_KEY").ok())?; info!("waiting for Meilisearch to be healthy"); wait_for_healthy(&client).await; info!("Meilisearch is healthy");