Update Meilisearch SDK (#53)
* Update Meilisearch SDK * Run Formatter * Fixes
This commit is contained in:
parent
017cf9e464
commit
2b1ed49e9a
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -34,6 +34,18 @@ dependencies = [
|
||||
"trust-dns-resolver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-cors"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a6206917d5c0fdd79d81cec9ef02d3e802df4abf276d96241e1f595d971e002"
|
||||
dependencies = [
|
||||
"actix-service",
|
||||
"actix-web",
|
||||
"derive_more",
|
||||
"futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-files"
|
||||
version = "0.2.2"
|
||||
@ -1146,6 +1158,7 @@ dependencies = [
|
||||
name = "labrinth"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-files",
|
||||
"actix-multipart",
|
||||
"actix-rt",
|
||||
@ -1278,8 +1291,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-sdk"
|
||||
version = "0.1.4"
|
||||
source = "git+https://github.com/Aeledfyr/meilisearch-rust#ba1f1e530cb383f421273f6863378bc9bc222f7b"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a9e61da1ebd3d15e0aaa978d3f1f080e3793494ddea0bc6703da4b330ea1ffc"
|
||||
dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
|
||||
@ -18,6 +18,8 @@ actix-files = "0.2.2"
|
||||
actix-multipart = "0.2.0"
|
||||
actix-cors = "0.2.0"
|
||||
|
||||
meilisearch-sdk = "0.3.0"
|
||||
|
||||
reqwest = {version="0.10.6", features=["json"]}
|
||||
|
||||
serde_json = "1.0"
|
||||
@ -50,8 +52,3 @@ git = "https://github.com/launchbadge/sqlx/"
|
||||
branch = "master"
|
||||
default-features = false
|
||||
features = ["runtime-actix", "postgres", "chrono", "offline"]
|
||||
|
||||
[dependencies.meilisearch-sdk]
|
||||
# Temp fork with some patches
|
||||
git = "https://github.com/Aeledfyr/meilisearch-rust"
|
||||
branch = "master"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{web, App, HttpServer, http};
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{http, web, App, HttpServer};
|
||||
use env_logger::Env;
|
||||
use gumdrop::Options;
|
||||
use log::{info, warn};
|
||||
@ -178,7 +178,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
|
||||
.allowed_header(http::header::CONTENT_TYPE)
|
||||
.max_age(3600)
|
||||
.finish()
|
||||
.finish(),
|
||||
)
|
||||
.wrap(Logger::default())
|
||||
.wrap(Logger::new("%a %{User-Agent}i"))
|
||||
|
||||
@ -129,9 +129,10 @@ async fn update_index<'a>(
|
||||
) -> Result<Index<'a>, IndexingError> {
|
||||
let index = match client.get_index(name).await {
|
||||
Ok(index) => index,
|
||||
Err(meilisearch_sdk::errors::Error::IndexNotFound) => {
|
||||
client.create_index(name, Some("mod_id")).await?
|
||||
}
|
||||
Err(meilisearch_sdk::errors::Error::MeiliSearchError {
|
||||
error_code: meilisearch_sdk::errors::ErrorCode::IndexNotFound,
|
||||
..
|
||||
}) => client.create_index(name, Some("mod_id")).await?,
|
||||
Err(e) => {
|
||||
return Err(IndexingError::IndexDBError(e));
|
||||
}
|
||||
@ -150,7 +151,10 @@ async fn create_index<'a>(
|
||||
match client.get_index(name).await {
|
||||
// TODO: update index settings on startup (or delete old indices on startup)
|
||||
Ok(index) => Ok(index),
|
||||
Err(meilisearch_sdk::errors::Error::IndexNotFound) => {
|
||||
Err(meilisearch_sdk::errors::Error::MeiliSearchError {
|
||||
error_code: meilisearch_sdk::errors::ErrorCode::IndexNotFound,
|
||||
..
|
||||
}) => {
|
||||
// Only create index and set settings if the index doesn't already exist
|
||||
let index = client.create_index(name, Some("mod_id")).await?;
|
||||
|
||||
@ -260,7 +264,6 @@ fn default_settings() -> Settings {
|
||||
Settings::new()
|
||||
.with_displayed_attributes(displayed_attributes)
|
||||
.with_searchable_attributes(searchable_attributes)
|
||||
.with_accept_new_fields(true)
|
||||
.with_stop_words(vec![])
|
||||
.with_synonyms(HashMap::new())
|
||||
.with_attributes_for_faceting(vec![String::from("categories"), String::from("host")])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user