mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
Merge #179
179: Enable filter paramater during search r=MarinPostma a=MarinPostma This pr makes the necessary changes to transplant in accordance with the specification on filters. More precisely, it: - Removes the `filters` parameter - Renames `facetFilters` to `filter` - Allows either a string or an array to be passed to the filter param. It doesn't allow the mixed syntax, that needs to be handled by milli. close #81 close #140 Co-authored-by: Marin Postma <postma.marin@protonmail.com>
This commit is contained in:
commit
d765397c82
2 changed files with 43 additions and 41 deletions
|
@ -2,6 +2,7 @@ use std::collections::HashSet;
|
|||
use std::convert::{TryFrom, TryInto};
|
||||
|
||||
use actix_web::{get, post, web, HttpResponse};
|
||||
use serde_json::Value;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::ResponseError;
|
||||
|
@ -24,9 +25,8 @@ pub struct SearchQueryGet {
|
|||
attributes_to_crop: Option<String>,
|
||||
crop_length: Option<usize>,
|
||||
attributes_to_highlight: Option<String>,
|
||||
filters: Option<String>,
|
||||
filter: Option<String>,
|
||||
matches: Option<bool>,
|
||||
facet_filters: Option<String>,
|
||||
facet_distributions: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,13 @@ impl TryFrom<SearchQueryGet> for SearchQuery {
|
|||
.facet_distributions
|
||||
.map(|attrs| attrs.split(',').map(String::from).collect::<Vec<_>>());
|
||||
|
||||
let facet_filters = match other.facet_filters {
|
||||
Some(ref f) => Some(serde_json::from_str(f)?),
|
||||
let filter = match other.filter {
|
||||
Some(f) => {
|
||||
match serde_json::from_str(&f) {
|
||||
Ok(v) => Some(v),
|
||||
_ => Some(Value::String(f)),
|
||||
}
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
|
||||
|
@ -63,9 +68,8 @@ impl TryFrom<SearchQueryGet> for SearchQuery {
|
|||
attributes_to_crop,
|
||||
crop_length: other.crop_length,
|
||||
attributes_to_highlight,
|
||||
filters: other.filters,
|
||||
filter,
|
||||
matches: other.matches,
|
||||
facet_filters,
|
||||
facet_distributions,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue