Skip to content

Commit

Permalink
Merge branch 'bump-meilisearch-v1.1.0' of github.com:meilisearch/meil…
Browse files Browse the repository at this point in the history
…isearch-rust into bump-meilisearch-v1.1.0
  • Loading branch information
bidoubiwa committed Mar 29, 2023
2 parents db82c10 + eaa535a commit 595ac29
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ impl Index {
/// { "id": 2, "body": "catto" }"#.as_bytes(),
/// "application/x-ndjson",
/// Some("id"),
/// None
/// ).await.unwrap();
/// // Meilisearch may take some time to execute the request so we are going to wait till it's completed
/// client.wait_for_task(task, None, None).await.unwrap();
Expand All @@ -604,15 +605,16 @@ impl Index {
payload: T,
content_type: &str,
primary_key: Option<&str>,
csv_delimiter: Option<&str>,
) -> Result<TaskInfo, Error> {
let url = if let Some(primary_key) = primary_key {
format!(
"{}/indexes/{}/documents?primaryKey={}",
self.client.host, self.uid, primary_key
)
} else {
format!("{}/indexes/{}/documents", self.client.host, self.uid)
};
let mut url = format!("{}/indexes/{}/documents?", self.client.host, self.uid);
if let Some(primary_key) = primary_key {
url = format!("{}primaryKey={}&", url, primary_key)
}

if let Some(csv_delimiter) = csv_delimiter {
url = format!("{}csvDelimiter={}", url, csv_delimiter)
}
stream_request::<(), T, TaskInfo>(
&url,
&self.client.api_key,
Expand Down Expand Up @@ -736,13 +738,14 @@ impl Index {
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
/// # futures::executor::block_on(async move {
/// let client = Client::new(MEILISEARCH_URL, MEILISEARCH_API_KEY);
/// let movie_index = client.index("add_or_replace_unchecked_payload");
/// let movie_index = client.index("add_or_update_unchecked_payload");
///
/// let task = movie_index.add_or_update_unchecked_payload(
/// r#"{ "id": 1, "body": "doggo" }
/// { "id": 2, "body": "catto" }"#.as_bytes(),
/// "application/x-ndjson",
/// Some("id"),
/// None
/// ).await.unwrap();
/// // Meilisearch may take some time to execute the request so we are going to wait till it's completed
/// client.wait_for_task(task, None, None).await.unwrap();
Expand All @@ -760,15 +763,18 @@ impl Index {
payload: T,
content_type: &str,
primary_key: Option<&str>,
csv_delimiter: Option<&str>,
) -> Result<TaskInfo, Error> {
let url = if let Some(primary_key) = primary_key {
format!(
"{}/indexes/{}/documents?primaryKey={}",
self.client.host, self.uid, primary_key
)
} else {
format!("{}/indexes/{}/documents", self.client.host, self.uid)
};
let mut url = format!("{}/indexes/{}/documents?", self.client.host, self.uid);

if let Some(primary_key) = primary_key {
url = format!("{}primaryKey={}&", url, primary_key)
}

if let Some(csv_delimiter) = csv_delimiter {
url = format!("{}csvDelimiter={}", url, csv_delimiter)
}

stream_request::<(), T, TaskInfo>(
&url,
&self.client.api_key,
Expand Down

0 comments on commit 595ac29

Please sign in to comment.