From 9cc31c2258e1dbc6dde592aab30c3c2ad66fd8ea Mon Sep 17 00:00:00 2001 From: marin postma Date: Tue, 22 Jun 2021 14:22:36 +0200 Subject: [PATCH] fix get search crop len --- meilisearch-http/src/index/mod.rs | 2 +- meilisearch-http/src/index/search.rs | 2 +- meilisearch-http/src/routes/search.rs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/meilisearch-http/src/index/mod.rs b/meilisearch-http/src/index/mod.rs index ca1518a2e..5a005fdc0 100644 --- a/meilisearch-http/src/index/mod.rs +++ b/meilisearch-http/src/index/mod.rs @@ -13,7 +13,7 @@ use serde_json::{Map, Value}; use crate::helpers::EnvSizer; use error::Result; -pub use search::{SearchQuery, SearchResult, DEFAULT_SEARCH_LIMIT}; +pub use search::{SearchQuery, SearchResult, DEFAULT_SEARCH_LIMIT, default_crop_length}; pub use updates::{Checked, Facets, Settings, Unchecked}; use self::error::IndexError; diff --git a/meilisearch-http/src/index/search.rs b/meilisearch-http/src/index/search.rs index 0a658ec30..6a03bdbb7 100644 --- a/meilisearch-http/src/index/search.rs +++ b/meilisearch-http/src/index/search.rs @@ -23,7 +23,7 @@ const fn default_search_limit() -> usize { } pub const DEFAULT_CROP_LENGTH: usize = 200; -const fn default_crop_length() -> usize { +pub const fn default_crop_length() -> usize { DEFAULT_CROP_LENGTH } diff --git a/meilisearch-http/src/routes/search.rs b/meilisearch-http/src/routes/search.rs index e8b197caa..192fd4994 100644 --- a/meilisearch-http/src/routes/search.rs +++ b/meilisearch-http/src/routes/search.rs @@ -6,7 +6,7 @@ use serde_json::Value; use crate::error::ResponseError; use crate::helpers::Authentication; -use crate::index::{SearchQuery, DEFAULT_SEARCH_LIMIT}; +use crate::index::{SearchQuery, default_crop_length, DEFAULT_SEARCH_LIMIT}; use crate::routes::IndexParam; use crate::Data; @@ -22,10 +22,12 @@ pub struct SearchQueryGet { limit: Option, attributes_to_retrieve: Option, attributes_to_crop: Option, + #[serde(default = "default_crop_length")] crop_length: usize, attributes_to_highlight: Option, filter: Option, - matches: Option, + #[serde(default = "Default::default")] + matches: bool, facet_distributions: Option, } @@ -64,7 +66,7 @@ impl From for SearchQuery { crop_length: other.crop_length, attributes_to_highlight, filter, - matches: other.matches, + matches: Some(other.matches), facet_distributions, } }