Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ add_or_update_documents_1: |-
id: usize,
title: String
}
impl Document for IncompleteMovie {
type UIDType = usize;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}

let task: Task = client.index("movies").add_or_update(&[
IncompleteMovie {
Expand Down Expand Up @@ -369,7 +365,6 @@ settings_guide_sortable_1: |-
add_movies_json_1: |-
use meilisearch_sdk::{
indexes::*,
document::*,
client::*,
search::*,
settings::*
Expand Down Expand Up @@ -397,10 +392,6 @@ documents_guide_add_movie_1: |-
id: String,
title: String
}
impl Document for IncompleteMovie {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}

// Add a document to our index
let task: Task = client.index("movies").add_documents(&[
Expand All @@ -420,10 +411,6 @@ document_guide_add_document_primary_key: |-
overview: String,
release_date: String
}
impl Document for Movie {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}

let task: Task = client.index("movies").add_documents(&[
Movie {
Expand Down Expand Up @@ -459,10 +446,6 @@ getting_started_add_documents_md: |-
release_date: i64,
genres: Vec<String>
}
impl Document for Movie {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}
```

You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes)
Expand All @@ -475,19 +458,13 @@ getting_started_add_documents_md: |-
#[serde(flatten)]
value: serde_json::Value,
}

impl Document for Movie {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}
```

Then, add documents into the index:

```rust
use meilisearch_sdk::{
indexes::*,
document::*,
client::*,
search::*,
settings::*
Expand Down Expand Up @@ -601,11 +578,6 @@ getting_started_add_meteorites: |-
_geo: Geo
}

impl Document for Meteorite {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}

let mut file = File::open("meteorites.json")?;
let meteorites: Vec<Meteorite> = serde_json::from_reader(file)?;

Expand Down Expand Up @@ -812,10 +784,6 @@ landing_getting_started_1: |-
id: String,
title: String
}
impl Document for Movie {
type UIDType = String;
fn get_uid(&self) -> &Self::UIDType { &self.id }
}

client.index("movies").add_documents(&[
Movie { "id": "1".to_string(), "title": "Carol".to_string() },
Expand Down
9 changes: 0 additions & 9 deletions examples/web_app/src/document.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use meilisearch_sdk::document::Document;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use yew::prelude::*;
Expand All @@ -15,14 +14,6 @@ pub struct Crate {
}

// Implement the Document trait so that we can use our struct with Meilisearch
impl Document for Crate {
type UIDType = String;

fn get_uid(&self) -> &Self::UIDType {
&self.name
}
}

fn get_readable_download_count(this: &Map<String, Value>) -> String {
if let Some(downloads) = this["downloads"].as_f64() {
if downloads < 1000.0 {
Expand Down
17 changes: 5 additions & 12 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl Client {
uid: impl AsRef<str>,
primary_key: Option<&str>,
) -> Result<Task, Error> {
Ok(request::<Value, Task>(
request::<Value, Task>(
&format!("{}/indexes", self.host),
&self.api_key,
Method::Post(json!({
Expand All @@ -185,19 +185,19 @@ impl Client {
})),
202,
)
.await?)
.await
}

/// Delete an index from its UID.
/// To delete an [Index], use the [Index::delete] method.
pub async fn delete_index(&self, uid: impl AsRef<str>) -> Result<Task, Error> {
Ok(request::<(), Task>(
request::<(), Task>(
&format!("{}/indexes/{}", self.host, uid.as_ref()),
&self.api_key,
Method::Delete,
202,
)
.await?)
.await
}

/// Alias for [Client::list_all_indexes].
Expand Down Expand Up @@ -467,7 +467,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, document, indexes::*, tasks::Task};
/// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task};
/// # use serde::{Serialize, Deserialize};
/// #
/// # #[derive(Debug, Serialize, Deserialize, PartialEq)]
Expand All @@ -477,13 +477,6 @@ impl Client {
/// # kind: String,
/// # }
/// #
/// # impl document::Document for Document {
/// # type UIDType = usize;
/// #
/// # fn get_uid(&self) -> &Self::UIDType {
/// # &self.id
/// # }
/// # }
/// #
/// # futures::executor::block_on(async move {
/// let client = Client::new("http://localhost:7700", "masterKey");
Expand Down
42 changes: 0 additions & 42 deletions src/document.rs

This file was deleted.

Loading