add search post route

This commit is contained in:
mpostma 2020-05-29 17:36:55 +02:00
parent 940105efb3
commit 6add10b18f
2 changed files with 5 additions and 7 deletions

View File

@ -70,7 +70,7 @@ async fn main() -> Result<(), MainError> {
Cors::new()
.send_wildcard()
.allowed_header("x-meili-api-key")
.max_age(86_400) // 24h
//.max_age(86_400) // 24h
.finish(),
)
.wrap(middleware::Logger::default())

View File

@ -17,7 +17,8 @@ use meilisearch_core::facets::FacetFilter;
use meilisearch_schema::{Schema, FieldId};
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(search_with_url_query);
cfg.service(search_with_post)
.service(search_with_url_query);
}
#[derive(Deserialize)]
@ -26,10 +27,7 @@ struct SearchQuery {
q: String,
offset: Option<usize>,
limit: Option<usize>,
attributes_to_retrieve: Option<String>,
attributes_to_crop: Option<String>,
crop_length: Option<usize>,
attributes_to_highlight: Option<String>,
attributes_to_retrieve: Option<String>, attributes_to_crop: Option<String>, crop_length: Option<usize>, attributes_to_highlight: Option<String>,
filters: Option<String>,
matches: Option<bool>,
facet_filters: Option<String>,
@ -50,7 +48,7 @@ async fn search_with_url_query(
async fn search_with_post(
data: web::Data<Data>,
path: web::Path<IndexParam>,
params: web::Query<SearchQuery>,
params: web::Json<SearchQuery>,
) -> Result<HttpResponse, ResponseError> {
let search_result = params.search(&path.index_uid, data)?;
Ok(HttpResponse::Ok().json(search_result))