Skip to content

Commit

Permalink
Merge branch 'main' into vector-search-embedder
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm authored Aug 14, 2024
2 parents 77399a2 + 38309ef commit c69358b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ primary_field_guide_add_document_primary_key: |-
getting_started_add_documents_md: |-
```toml
[dependencies]
meilisearch-sdk = "0.27.0"
meilisearch-sdk = "0.27.1"
# futures: because we want to block on futures
futures = "0.3"
# serde: required if you are going to use documents
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "meilisearch-sdk"
version = "0.27.0"
version = "0.27.1"
authors = ["Mubelotix <[email protected]>"]
edition = "2018"
description = "Rust wrapper for the Meilisearch API. Meilisearch is a powerful, fast, open-source, easy to use and deploy search engine."
Expand All @@ -21,7 +21,7 @@ time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsi
yaup = "0.3.1"
either = { version = "1.8.0", features = ["serde"] }
thiserror = "1.0.37"
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.27.0" }
meilisearch-index-setting-macro = { path = "meilisearch-index-setting-macro", version = "0.27.1" }
pin-project-lite = { version = "0.2.13", optional = true }
reqwest = { version = "0.12.3", optional = true, default-features = false, features = ["rustls-tls", "http2", "stream"] }
bytes = { version = "1.6", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ To use `meilisearch-sdk`, add this to your `Cargo.toml`:

```toml
[dependencies]
meilisearch-sdk = "0.27.0"
meilisearch-sdk = "0.27.1"
```

The following optional dependencies may also be useful:
Expand Down
2 changes: 1 addition & 1 deletion README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ To use `meilisearch-sdk`, add this to your `Cargo.toml`:

```toml
[dependencies]
meilisearch-sdk = "0.27.0"
meilisearch-sdk = "0.27.1"
```

The following optional dependencies may also be useful:
Expand Down
2 changes: 1 addition & 1 deletion examples/web_app_graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actix-web = "4.4.0"
async-graphql = "6.0.11"
async-graphql-actix-web = "6.0.11"
diesel = { version = "2.1.4", features = ["postgres"] }
diesel-async = { version = "0.4.1", features = ["postgres", "deadpool"] }
diesel-async = { version = "0.5.0", features = ["postgres", "deadpool"] }
diesel_migrations = "2.1.0"
dotenvy = "0.15.7"
env_logger = "0.11.3"
Expand Down
2 changes: 1 addition & 1 deletion meilisearch-index-setting-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "meilisearch-index-setting-macro"
version = "0.27.0"
version = "0.27.1"
description = "Helper tool to generate settings of a Meilisearch index"
edition = "2021"
license = "MIT"
Expand Down
37 changes: 29 additions & 8 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde::de::Error as SerdeError;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::{json, Value};
use std::{collections::HashMap, time::Duration};
Expand Down Expand Up @@ -79,16 +80,36 @@ impl<Http: HttpClient> Client<Http> {
&self,
value: &Value,
) -> Result<IndexesResults<Http>, Error> {
let raw_indexes = value["results"].as_array().unwrap();
let raw_indexes = value["results"]
.as_array()
.ok_or_else(|| serde_json::Error::custom("Missing or invalid 'results' field"))
.map_err(Error::ParseError)?;

let limit = value["limit"]
.as_u64()
.ok_or_else(|| serde_json::Error::custom("Missing or invalid 'limit' field"))
.map_err(Error::ParseError)? as u32;

let offset = value["offset"]
.as_u64()
.ok_or_else(|| serde_json::Error::custom("Missing or invalid 'offset' field"))
.map_err(Error::ParseError)? as u32;

let total = value["total"]
.as_u64()
.ok_or_else(|| serde_json::Error::custom("Missing or invalid 'total' field"))
.map_err(Error::ParseError)? as u32;

let results = raw_indexes
.iter()
.map(|raw_index| Index::from_value(raw_index.clone(), self.clone()))
.collect::<Result<_, _>>()?;

let indexes_results = IndexesResults {
limit: value["limit"].as_u64().unwrap() as u32,
offset: value["offset"].as_u64().unwrap() as u32,
total: value["total"].as_u64().unwrap() as u32,
results: raw_indexes
.iter()
.map(|raw_index| Index::from_value(raw_index.clone(), self.clone()))
.collect::<Result<_, _>>()?,
limit,
offset,
total,
results,
};

Ok(indexes_results)
Expand Down
1 change: 1 addition & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum Error {
/// The Meilisearch server returned an invalid JSON for a request.
#[error("Error parsing response JSON: {}", .0)]
ParseError(#[from] serde_json::Error),

/// A timeout happened while waiting for an update to complete.
#[error("A task did not succeed in time.")]
Timeout,
Expand Down

0 comments on commit c69358b

Please sign in to comment.