mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 09:04:59 +08:00
add search post route
This commit is contained in:
parent
940105efb3
commit
6add10b18f
@ -70,7 +70,7 @@ async fn main() -> Result<(), MainError> {
|
|||||||
Cors::new()
|
Cors::new()
|
||||||
.send_wildcard()
|
.send_wildcard()
|
||||||
.allowed_header("x-meili-api-key")
|
.allowed_header("x-meili-api-key")
|
||||||
.max_age(86_400) // 24h
|
//.max_age(86_400) // 24h
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
|
@ -17,7 +17,8 @@ use meilisearch_core::facets::FacetFilter;
|
|||||||
use meilisearch_schema::{Schema, FieldId};
|
use meilisearch_schema::{Schema, FieldId};
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
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)]
|
#[derive(Deserialize)]
|
||||||
@ -26,10 +27,7 @@ struct SearchQuery {
|
|||||||
q: String,
|
q: String,
|
||||||
offset: Option<usize>,
|
offset: Option<usize>,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
attributes_to_retrieve: Option<String>,
|
attributes_to_retrieve: Option<String>, attributes_to_crop: Option<String>, crop_length: Option<usize>, attributes_to_highlight: Option<String>,
|
||||||
attributes_to_crop: Option<String>,
|
|
||||||
crop_length: Option<usize>,
|
|
||||||
attributes_to_highlight: Option<String>,
|
|
||||||
filters: Option<String>,
|
filters: Option<String>,
|
||||||
matches: Option<bool>,
|
matches: Option<bool>,
|
||||||
facet_filters: Option<String>,
|
facet_filters: Option<String>,
|
||||||
@ -50,7 +48,7 @@ async fn search_with_url_query(
|
|||||||
async fn search_with_post(
|
async fn search_with_post(
|
||||||
data: web::Data<Data>,
|
data: web::Data<Data>,
|
||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
params: web::Query<SearchQuery>,
|
params: web::Json<SearchQuery>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let search_result = params.search(&path.index_uid, data)?;
|
let search_result = params.search(&path.index_uid, data)?;
|
||||||
Ok(HttpResponse::Ok().json(search_result))
|
Ok(HttpResponse::Ok().json(search_result))
|
||||||
|
Loading…
Reference in New Issue
Block a user