1
0

Update Meilisearch SDK (#53)

* Update Meilisearch SDK

* Run Formatter

* Fixes
This commit is contained in:
Geometrically
2020-08-27 17:53:40 -07:00
committed by GitHub
parent 017cf9e464
commit 2b1ed49e9a
4 changed files with 29 additions and 15 deletions

View File

@@ -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"))

View File

@@ -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")])