-
Notifications
You must be signed in to change notification settings - Fork 102
Closed as not planned
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Not sure if this is a bug or a feature request.
SearchResults doesn't seem to have the serde serialize trait, this prevents passing the results to something like actix httpresponse json.
code block
#[macro_use]
extern crate diesel;
extern crate env_logger;
use std::env;
use actix_cors::Cors;
use actix_web::{
delete, get, middleware, patch, post,
web::{self, Data},
App, HttpRequest, HttpResponse, HttpServer,
};
use serde::{Deserialize, Serialize};
use serde_json::Result;
use chrono::{DateTime, Utc};
use meilisearch_sdk::client::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct Posting {
pub id: uuid::Uuid,
pub title: String,
pub link: String,
pub rating: i32,
pub summary: Option<String>,
pub updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
}
#[get("/search-test")]
async fn get_r_search_test(
req: HttpRequest,
meili_client: web::Data<meilisearch_sdk::client::Client>,
) -> Result<HttpResponse> {
let results = meili_client
.index("movies")
.search()
.with_query("Apple")
.execute::<crate::models::Posting>()
.await
.unwrap();
println!("{:?}", results);
// ERROR LINE
Ok(HttpResponse::Ok().json(results))
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenvy::dotenv().ok();
let meilisearch_url = env::var("MEILISEARCH_URL").expect("Meilisearch URL env not found");
let meilisearch_master_key = env::var("MEILISEARCH_MASTER_KEY").expect("Meilisearch master API key env not found");
let meilisearch_client = Client::new(&meilisearch_url, Some(meilisearch_master_key));
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
HttpServer::new(move || {
App::new()
.app_data(Data::new(meilisearch_client.clone()))
.wrap(middleware::Logger::default())
.wrap(Cors::permissive())
.service(web::scope("/api/v1").service(get_r_search_test))
})
.bind("127.0.0.1:9004")?
.run()
.await
}
Expected behavior
SearchResults will have the serde serialize trait.
Current behavior
HttpResponse::Ok().json(results)
---- ^^^^^^^ the trait _::_serde::Serialize
is not implemented for SearchResults<Posting>
Screenshots or Logs
N/A
Environment (please complete the following information):
- OS: Windows 10 x64
- Meilisearch version: 1.3.3
- meilisearch-rust version: 0.24.1
ZelCloud and MarioHabor
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request