mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
Introduce a boostingFilter search parameter
This commit is contained in:
parent
2495058a6e
commit
f2041fd78c
@ -235,6 +235,7 @@ InvalidSearchCropMarker , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchFacets , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidFacetSearchFacetName , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchFilter , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchBoostingFilter , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchHighlightPostTag , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchHighlightPreTag , InvalidRequest , BAD_REQUEST ;
|
||||
InvalidSearchHitsPerPage , InvalidRequest , BAD_REQUEST ;
|
||||
|
@ -629,6 +629,7 @@ impl SearchAggregator {
|
||||
show_ranking_score,
|
||||
show_ranking_score_details,
|
||||
filter,
|
||||
boosting_filter,
|
||||
sort,
|
||||
facets: _,
|
||||
highlight_pre_tag,
|
||||
@ -1002,6 +1003,7 @@ impl MultiSearchAggregator {
|
||||
show_ranking_score_details: _,
|
||||
show_matches_position: _,
|
||||
filter: _,
|
||||
boosting_filter: _,
|
||||
sort: _,
|
||||
facets: _,
|
||||
highlight_pre_tag: _,
|
||||
|
@ -111,6 +111,7 @@ impl From<FacetSearchQuery> for SearchQuery {
|
||||
show_ranking_score: false,
|
||||
show_ranking_score_details: false,
|
||||
filter,
|
||||
boosting_filter: None,
|
||||
sort: None,
|
||||
facets: None,
|
||||
highlight_pre_tag: DEFAULT_HIGHLIGHT_PRE_TAG(),
|
||||
|
@ -54,6 +54,8 @@ pub struct SearchQueryGet {
|
||||
attributes_to_highlight: Option<CS<String>>,
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidSearchFilter>)]
|
||||
filter: Option<String>,
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidSearchBoostingFilter>)]
|
||||
boosting_filter: Option<String>,
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidSearchSort>)]
|
||||
sort: Option<String>,
|
||||
#[deserr(default, error = DeserrQueryParamError<InvalidSearchShowMatchesPosition>)]
|
||||
@ -86,6 +88,14 @@ impl From<SearchQueryGet> for SearchQuery {
|
||||
None => None,
|
||||
};
|
||||
|
||||
let boosting_filter = match other.boosting_filter {
|
||||
Some(f) => match serde_json::from_str(&f) {
|
||||
Ok(v) => Some(v),
|
||||
_ => Some(Value::String(f)),
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
|
||||
Self {
|
||||
q: other.q,
|
||||
vector: other.vector.map(CS::into_inner),
|
||||
@ -98,6 +108,7 @@ impl From<SearchQueryGet> for SearchQuery {
|
||||
crop_length: other.crop_length.0,
|
||||
attributes_to_highlight: other.attributes_to_highlight.map(|o| o.into_iter().collect()),
|
||||
filter,
|
||||
boosting_filter,
|
||||
sort: other.sort.map(|attr| fix_sort_query_parameters(&attr)),
|
||||
show_matches_position: other.show_matches_position.0,
|
||||
show_ranking_score: other.show_ranking_score.0,
|
||||
|
@ -71,6 +71,8 @@ pub struct SearchQuery {
|
||||
pub show_ranking_score_details: bool,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchFilter>)]
|
||||
pub filter: Option<Value>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchBoostingFilter>)]
|
||||
pub boosting_filter: Option<Value>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchSort>)]
|
||||
pub sort: Option<Vec<String>>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchFacets>)]
|
||||
@ -130,6 +132,8 @@ pub struct SearchQueryWithIndex {
|
||||
pub show_matches_position: bool,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchFilter>)]
|
||||
pub filter: Option<Value>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchBoostingFilter>)]
|
||||
pub boosting_filter: Option<Value>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchSort>)]
|
||||
pub sort: Option<Vec<String>>,
|
||||
#[deserr(default, error = DeserrJsonError<InvalidSearchFacets>)]
|
||||
@ -164,6 +168,7 @@ impl SearchQueryWithIndex {
|
||||
show_ranking_score_details,
|
||||
show_matches_position,
|
||||
filter,
|
||||
boosting_filter,
|
||||
sort,
|
||||
facets,
|
||||
highlight_pre_tag,
|
||||
@ -189,6 +194,7 @@ impl SearchQueryWithIndex {
|
||||
show_ranking_score_details,
|
||||
show_matches_position,
|
||||
filter,
|
||||
boosting_filter,
|
||||
sort,
|
||||
facets,
|
||||
highlight_pre_tag,
|
||||
@ -397,8 +403,14 @@ fn prepare_search<'t>(
|
||||
search.limit(limit);
|
||||
|
||||
if let Some(ref filter) = query.filter {
|
||||
if let Some(facets) = parse_filter(filter)? {
|
||||
search.filter(facets);
|
||||
if let Some(filter) = parse_filter(filter)? {
|
||||
search.filter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref boosting_filter) = query.boosting_filter {
|
||||
if let Some(boosting_filter) = parse_filter(boosting_filter)? {
|
||||
search.boosting_filter(boosting_filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user