Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc #87

Closed
wants to merge 22 commits into from
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
79 changes: 37 additions & 42 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,15 @@ update_settings_1: |-
])
.with_distinct_attribute("movie_id".to_string())
.with_searchable_attributes(vec![
"uid".to_string(),
"movie_id".to_string(),
"title".to_string(),
"description".to_string(),
"poster".to_string(),
"release_date".to_string(),
"rank".to_string()
"genre".to_string()
])
.with_displayed_attributes(vec![
"title".to_string(),
"description".to_string(),
"poster".to_string(),
"release_date".to_string(),
"rank".to_string()
"genre".to_string(),
"release_date".to_string()
])
.with_stop_words(vec![
"the".to_string(),
Expand Down Expand Up @@ -157,7 +152,7 @@ update_searchable_attributes_1: |-
let searchable_attributes = &[
"title",
"description",
"uid"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
Expand All @@ -180,9 +175,8 @@ update_displayed_attributes_1: |-
let displayed_attributes = &[
"title",
"description",
"release_date",
"rank",
"poster"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand All @@ -202,23 +196,18 @@ distinct_attribute_guide_1: |-
let progress: Progress = jackets.set_distinct_attribute("product_id").await.unwrap();
field_properties_guide_searchable_1: |-
let searchable_attributes = &[
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
field_properties_guide_displayed_1: |-
let displayed_attributes = &[
"title",
"description",
"poster",
"release_date",
"rank"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand Down Expand Up @@ -353,23 +342,18 @@ settings_guide_distinct_1: |-
let progress: Progress = jackets.set_distinct_attribute("product_id").await.unwrap();
settings_guide_searchable_1: |-
let searchable_attributes = &[
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
settings_guide_displayed_1: |-
let displayed_attributes = &[
"title",
"description",
"poster",
"release_date",
"rank"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand Down Expand Up @@ -407,31 +391,29 @@ search_guide_2: |-
.execute()
.await
.unwrap();
getting_started_create_index_md: |-
getting_started_add_documents_md: |-
```toml
[dependencies]
meilisearch-sdk = "0.4"
tokio = { version = "0.2", features = ["macros"] } # required if you are not targeting wasm
futures = "0.3" # because we want to block on futures
serde = { version="1.0", features = ["derive"] } # required if you are going to use documents
serde_json = "1.0" # required in some parts of this guide
```

```rust
use meilisearch_sdk::{indexes::*, document::*, client::*, search::*, progress::*, settings::*};
use serde::{Serialize, Deserialize};
use futures::executor::block_on;

#[tokio::main]
async fn main() {
fn main() { block_on(async move {
let client = Client::new("http://localhost:7700", "masterKey");
// create an index if the index does not exist
let movies = client.get_or_create("movies").await.unwrap();

// some code
}
})}
```

[About this crate](https://github.com/meilisearch/meilisearch-rust)
getting_started_add_documents_md: |-
Documents in the Rust library are strongly typed.
You have to implement the `Document` trait on a struct to be able to use it with Meilisearch.

Expand Down Expand Up @@ -471,16 +453,27 @@ getting_started_add_documents_md: |-
Then, add documents into the index:

```rust
// reading and parsing the file
use meilisearch_sdk::{indexes::*, document::*, client::*, search::*, progress::*, settings::*};
use serde::{Serialize, Deserialize};
use std::{io::prelude::*, fs::File};
let mut file = File::open("movies.json").unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
let movies_docs: Vec<Movie> = serde_json::from_str(&content).unwrap();

// adding documents
movies.add_documents(&movies_docs, None).await.unwrap();
#[tokio::main]
async fn main() {
let client = Client::new("http://localhost:7700", "masterKey");

// reading and parsing the file
let mut file = File::open("movies.json").unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
let movies_docs: Vec<Movie> = serde_json::from_str(&content).unwrap();

// adding documents
let movies = client.get_or_create_index("movies").await.unwrap();
movies.add_documents(&movies_docs, None).await.unwrap();
}
```

[About this package](https://github.com/meilisearch/meilisearch-rust/)
getting_started_search_md: |-
You can build a Query and execute it later:
```rust
Expand Down Expand Up @@ -508,6 +501,8 @@ getting_started_search_md: |-
.await
.unwrap();
```

[About this package](https://github.com/meilisearch/meilisearch-rust/)
faceted_search_update_settings_1: |-
let progress: Progress = movies.set_attributes_for_faceting(&["director", "genres"]).await.unwrap();
faceted_search_facet_filters_1: |-
Expand Down
78 changes: 39 additions & 39 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ First of all, thank you for contributing to MeiliSearch! The goal of this docume
- [How to Contribute](#how-to-contribute)
- [Development Workflow](#development-workflow)
- [Git Guidelines](#git-guidelines)
- [Release Process (for Admin only)](#release-process-for-admin-only)

<!-- /MarkdownTOC -->

Expand All @@ -23,7 +24,7 @@ First of all, thank you for contributing to MeiliSearch! The goal of this docume
2. Once done, [fork the meilisearch-rust repository](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) in your own GitHub account. Ask a maintainer if you want your issue to be checked before making a PR.
3. [Create a new Git branch](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository).
4. Review the [Development Workflow](#workflow) section that describes the steps to maintain the repository.
5. Make your changes.
5. Make the changes on your branch.
6. [Submit the branch as a PR](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) pointing to the `master` branch of the main meilisearch-rust repository. A maintainer should comment and/or review your Pull Request within a few days. Although depending on the circumstances, it may take longer.<br>
We do not enforce a naming convention for the PRs, but **please use something descriptive of your changes**, having in mind that the title of your PR will be automatically added to the next [release changelog](https://github.com/meilisearch/meilisearch-rust/releases/).

Expand Down Expand Up @@ -88,25 +89,48 @@ $ sh scripts/check-readme.sh --diff

If it's not, the CI will fail on your PR.

### Release Process
## Git Guidelines

MeiliSearch tools follow the [Semantic Versioning Convention](https://semver.org/).
### Git Branches

All changes must be made in a branch and submitted as PR.
We do not enforce any branch naming style, but please use something descriptive of your changes.

### Git Commits

As minimal requirements, your commit message should:
- be capitalized
- not finish by a dot or any other punctuation character (!,?)
- start with a verb so that we can read your commit message this way: "This commit will ...", where "..." is the commit message.
e.g.: "Fix the home page button" or "Add more tests for create_index method"

We don't follow any other convention, but if you want to use one, we recommend [this one](https://chris.beams.io/posts/git-commit/).

#### Automated Changelogs
### GitHub Pull Requests

For each PR merged on `master`, a GitHub Action is running and updates the next release description as a draft release in the [GitHub interface](https://github.com/meilisearch/meilisearch-rust/releases). If you don't have the right access to this repository, you will not be able to see the draft release until the release is published.
Some notes on GitHub PRs:

- [Convert your PR as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) if your changes are a work in progress: no one will review it until you pass your PR as ready for review.<br>
The draft PR can be very useful if you want to show that you are working on something and make your work visible.
- The branch related to the PR must be **up-to-date with `master`** before merging. Fortunately, this project [integrates a bot](https://github.com/meilisearch/integration-guides/blob/master/guides/bors.md) to automatically enforce this requirement without the PR author having to do it manually..
- All PRs must be reviewed and approved by at least one maintainer.
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-rust/releases/).

## Release Process (for Admin only)

MeiliSearch tools follow the [Semantic Versioning Convention](https://semver.org/).

The draft release description is therefore generated and corresponds to all the PRs titles since the previous release. This means each PR should only do one change and the title should be descriptive of this change.
### Automation to Rebase and Merge the PRs

About this automation:
- As the draft release description is generated on every push on `master`, don't change it manually until the final release publishment.
- If you don't want a PR to appear in the release changelogs: add the label `skip-changelog`. We suggest removing PRs updating the README or the CI (except for big changes).
- If the changes you are doing in the PR are breaking: add the label `breaking-change`. In the release tag, the minor will be increased instead of the patch. The major will never be changed until [MeiliSearch](https://github.com/meilisearch/MeiliSearch) is stable.
- If you did any mistake, for example the PR is already closed but you forgot to add a label or you misnamed your PR, don't panic: change what you want in the closed PR and run the job again.
This project integrates a bot that helps us manage pull requests merging.<br>
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/master/guides/bors.md)._

*More information about the [Release Drafter](https://github.com/release-drafter/release-drafter), used to automate these steps.*
### Automated Changelogs

#### How to Publish the Release
This project integrates a tool to create automated changelogs.<br>
_[Read more about this](https://github.com/meilisearch/integration-guides/blob/master/guides/release-drafter.md)._

### How to Publish the Release

Make a PR modifying the file [`Cargo.toml`](/Cargo.toml):

Expand Down Expand Up @@ -136,32 +160,8 @@ Also, you might need to change the [code-samples file](/.code-samples.meilisearc

Once the changes are merged on `master`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-rust/releases).

A GitHub Action will be triggered and push the package to [crates.io](https://crates.io/crates/meilisearch-sdk).

## Git Guidelines
GitHub Actions will be triggered and push the package to [crates.io](https://crates.io/crates/meilisearch-sdk).

### Git Branches

All changes must be made in a branch and submitted as PR.
We do not enforce any branch naming style, but please use something descriptive of your changes.

### Git Commits

As minimal requirements, your commit message should:
- be capitalized
- not finish by a dot or any other punctuation character (!,?)
- start with a verb so that we can read your commit message this way: "This commit will ...", where "..." is the commit message.
e.g.: "Fix the home page button" or "Add more tests for create_index method"

We don't follow any other convention, but if you want to use one, we recommend [this one](https://chris.beams.io/posts/git-commit/).

### GitHub Pull Requests

Some notes on GitHub PRs:
- [Convert your PR as a draft](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) if your changes are a work in progress: no one will review it until you pass your PR as ready for review.<br>
The draft PR can be very useful if you want to show that you are working on something and make your work visible.
- The branch related to the PR must be **up-to-date with `master`** before merging. [Bors](https://github.com/bors-ng/bors-ng) will rebase your branch if it is not. Ask a maintainer to run it.
- All PRs must be reviewed and approved by at least one maintainer.
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-rust/releases/).
<hr>

Thank you again for reading this through, we can not wait to begin to work with you if you made your way through this contributing guide ❤️
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<h4 align="center">
<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> |
<a href="https://docs.meilisearch.com">Documentation</a> |
<a href="https://slack.meilisearch.com">Slack</a> |
<a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
<a href="https://www.meilisearch.com">Website</a> |
<a href="https://blog.meilisearch.com">Blog</a> |
<a href="https://twitter.com/meilisearch">Twitter</a> |
<a href="https://docs.meilisearch.com/faq">FAQ</a>
</h4>

Expand All @@ -23,13 +22,14 @@
<a href="https://github.com/meilisearch/meilisearch-rust/actions"><img src="https://github.com/meilisearch/meilisearch-rust/workflows/Tests/badge.svg?branch=master" alt="Tests"></a>
<a href="https://github.com/meilisearch/meilisearch-rust/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
<a href="https://github.com/meilisearch/MeiliSearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
<a href="https://slack.meilisearch.com"><img src="https://img.shields.io/badge/slack-MeiliSearch-blue.svg?logo=slack" alt="Slack"></a>
<a href="https://app.bors.tech/repositories/28502"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
</p>

<p align="center">⚡ The MeiliSearch API client written for Rust 🦀</p>

**MeiliSearch Rust** is the MeiliSearch API client for Rust developers. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets, and synonyms are provided out-of-the-box.
**MeiliSearch Rust** is the MeiliSearch API client for Rust developers.

**MeiliSearch** is an open-source search engine. [Discover what MeiliSearch is!](https://github.com/meilisearch/MeiliSearch)

## Table of Contents

Expand All @@ -56,12 +56,10 @@ meilisearch-sdk = "0.4.0"
The following optional dependencies may also be useful:

```toml
tokio = { version = "0.2", features = ["macros"] }
futures = "0.3" # To be able to block on async functions if you are not using an async runtime
serde = { version = "1.0", features = ["derive"] }
```

Since this crate is async, you have to run your program in the [tokio](https://crates.io/crates/tokio) runtime. When targetting Wasm, the browser will replace tokio.

Using this crate is possible without [serde](https://crates.io/crates/serde), but a lot of features require serde.

### Run a MeiliSearch Instance
Expand Down
8 changes: 4 additions & 4 deletions README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<h4 align="center">
<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> |
<a href="https://docs.meilisearch.com">Documentation</a> |
<a href="https://slack.meilisearch.com">Slack</a> |
<a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
<a href="https://www.meilisearch.com">Website</a> |
<a href="https://blog.meilisearch.com">Blog</a> |
<a href="https://twitter.com/meilisearch">Twitter</a> |
<a href="https://docs.meilisearch.com/faq">FAQ</a>
</h4>

Expand All @@ -23,13 +22,14 @@
<a href="https://github.com/meilisearch/meilisearch-rust/actions"><img src="https://github.com/meilisearch/meilisearch-rust/workflows/Tests/badge.svg?branch=master" alt="Tests"></a>
<a href="https://github.com/meilisearch/meilisearch-rust/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
<a href="https://github.com/meilisearch/MeiliSearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
<a href="https://slack.meilisearch.com"><img src="https://img.shields.io/badge/slack-MeiliSearch-blue.svg?logo=slack" alt="Slack"></a>
<a href="https://app.bors.tech/repositories/28502"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
</p>

<p align="center">⚡ The MeiliSearch API client written for Rust 🦀</p>

**MeiliSearch Rust** is the MeiliSearch API client for Rust developers. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets, and synonyms are provided out-of-the-box.
**MeiliSearch Rust** is the MeiliSearch API client for Rust developers.

**MeiliSearch** is an open-source search engine. [Discover what MeiliSearch is!](https://github.com/meilisearch/MeiliSearch)

## Table of Contents

Expand Down
6 changes: 5 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ impl From<&serde_json::Value> for Error {
#[cfg(not(target_arch = "wasm32"))]
impl From<isahc::Error> for Error {
fn from(error: isahc::Error) -> Error {
Error::HttpError(error)
if error.kind() == isahc::error::ErrorKind::ConnectionFailed {
Error::UnreachableServer
} else {
Error::HttpError(error)
}
}
}
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
//! The following optional dependencies may also be useful:
//!
//! ```toml
//! tokio = { version = "0.2", features = ["macros"] }
//! futures = "0.3" # To be able to block on async functions if you are not using an async runtime
//! serde = { version = "1.0", features = ["derive"] }
//! ```
//!
//! Since this crate is async, you have to run your program in the [tokio](https://crates.io/crates/tokio) runtime. When targetting Wasm, the browser will replace tokio.
//!
//! Using this crate is possible without [serde](https://crates.io/crates/serde), but a lot of features require serde.
//!
//! ## Run a MeiliSearch Instance
Expand Down