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

Rename MeiliSearch to Meilisearch #384

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
70 changes: 35 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ gem 'meilisearch-rails'
Create a new file `config/initializers/meilisearch.rb` to setup your `MEILISEARCH_HOST` and `MEILISEARCH_API_KEY`

```ruby
MeiliSearch::Rails.configuration = {
Meilisearch::Rails.configuration = {
meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://localhost:7700'),
meilisearch_api_key: ENV.fetch('MEILISEARCH_API_KEY', 'YourMeilisearchAPIKey')
}
Expand All @@ -120,7 +120,7 @@ The following code will create a `Book` index and add search capabilities to you

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch do
attribute :title, :author # only the attributes 'title', and 'author' will be sent to Meilisearch
Expand Down Expand Up @@ -154,7 +154,7 @@ Requests made to Meilisearch may timeout and retry. To adapt the behavior to
your needs, you can change the parameters during configuration:

```ruby
MeiliSearch::Rails.configuration = {
Meilisearch::Rails.configuration = {
meilisearch_url: 'YourMeilisearchUrl',
meilisearch_api_key: 'YourMeilisearchAPIKey',
timeout: 2,
Expand All @@ -172,7 +172,7 @@ You can configure the index settings by adding them inside the `meilisearch` blo

```ruby
class Book < ApplicationRecord
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch do
searchable_attributes [:title, :author, :publisher, :description]
Expand Down Expand Up @@ -235,7 +235,7 @@ Book.search('*', sort: ['title:asc'])
Meilisearch supports searching multiple models at the same time (see [🔍 Custom search](#-custom-search) for search options):

```ruby
multi_search_results = MeiliSearch::Rails.multi_search(
multi_search_results = Meilisearch::Rails.multi_search(
Book => { q: 'Harry' },
Manga => { q: 'Attack' }
)
Expand Down Expand Up @@ -295,7 +295,7 @@ This gem supports:
Specify the `:pagination_backend` in the configuration file:

```ruby
MeiliSearch::Rails.configuration = {
Meilisearch::Rails.configuration = {
meilisearch_url: 'YourMeilisearchUrl',
meilisearch_api_key: 'YourMeilisearchAPIKey',
pagination_backend: :kaminari # :will_paginate
Expand Down Expand Up @@ -344,7 +344,7 @@ Then in your model you must extend `Pagy::Meilisearch`:

```rb
class Book < ApplicationRecord
include MeiliSearch::Rails
include Meilisearch::Rails
extend Pagy::Meilisearch

meilisearch # ...
Expand All @@ -365,7 +365,7 @@ end
<%== pagy_nav(@pagy) %>
```

:warning: There is no need to set `pagination_backend` in the configuration block `MeiliSearch::Rails.configuration` for `pagy`.
:warning: There is no need to set `pagination_backend` in the configuration block `Meilisearch::Rails.configuration` for `pagy`.

Check [`ddnexus/pagy`](https://ddnexus.github.io/pagy/extras/meilisearch) for more information.

Expand All @@ -377,7 +377,7 @@ you have multiple ways to achieve this.
By adding `active: false` in the configuration initializer:

```ruby
MeiliSearch::Rails.configuration = {
Meilisearch::Rails.configuration = {
meilisearch_url: 'YourMeilisearchUrl',
meilisearch_api_key: 'YourMeilisearchAPIKey',
active: false
Expand All @@ -387,11 +387,11 @@ MeiliSearch::Rails.configuration = {
Or you can disable programmatically:

```ruby
MeiliSearch::Rails.deactivate! # all the following HTTP calls will be dismissed.
Meilisearch::Rails.deactivate! # all the following HTTP calls will be dismissed.

# or you can pass a block to it:

MeiliSearch::Rails.deactivate! do
Meilisearch::Rails.deactivate! do
# every Meilisearch call here will be dismissed, no error will be raised.
# after the block, Meilisearch state will be active.
end
Expand All @@ -400,7 +400,7 @@ end
You can also activate if you deactivated earlier:

```ruby
MeiliSearch::Rails.activate!
Meilisearch::Rails.activate!
```

:warning: These calls are persistent, so prefer to use the method with the block. This way, you will not forget to activate it afterward.
Expand All @@ -411,7 +411,7 @@ By default, the **index_uid** will be the class name, e.g. `Book`. You can custo

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch index_uid: 'MyCustomUID'
end
Expand All @@ -422,7 +422,7 @@ end
You can suffix the index UID with the current Rails environment by setting it globally:

```ruby
MeiliSearch::Rails.configuration = {
Meilisearch::Rails.configuration = {
meilisearch_url: 'YourMeilisearchUrl',
meilisearch_api_key: 'YourMeilisearchAPIKey',
per_environment: true
Expand All @@ -441,7 +441,7 @@ You can add a custom attribute by using the `add_attribute` option or by using a

```ruby
class Author < ApplicationRecord
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch do
attribute :first_name, :last_name
Expand Down Expand Up @@ -473,7 +473,7 @@ Note that the primary key must return a **unique value** otherwise your data cou

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch primary_key: :isbn # isbn is a column in your table definition.
end
Expand All @@ -484,7 +484,7 @@ will be used as the reference to the document when Meilisearch needs it.

```rb
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch primary_key: :my_custom_ms_id

Expand All @@ -503,7 +503,7 @@ As soon as you use those constraints, `add_documents` and `delete_documents` cal

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch if: :published?, unless: :premium?

Expand All @@ -526,7 +526,7 @@ You can index a record in several indexes using the `add_index` option:

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

PUBLIC_INDEX_UID = 'Books'
SECURED_INDEX_UID = 'PrivateBooks'
Expand Down Expand Up @@ -555,7 +555,7 @@ You may want to share an index between several models. You'll need to ensure you

```ruby
class Cat < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch index_uid: 'Animals', primary_key: :ms_id

Expand All @@ -567,7 +567,7 @@ class Cat < ActiveRecord::Base
end

class Dog < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch index_uid: 'Animals', primary_key: :ms_id

Expand All @@ -585,7 +585,7 @@ You can configure the auto-indexing & auto-removal process to use a queue to per

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch enqueue: true # ActiveJob will be triggered using a `meilisearch` queue
end
Expand All @@ -599,7 +599,7 @@ With **ActiveJob**:

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch enqueue: :trigger_job do
attribute :title, :author, :description
Expand Down Expand Up @@ -629,7 +629,7 @@ With [**Sidekiq**](https://github.com/mperham/sidekiq):

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch enqueue: :trigger_sidekiq_job do
attribute :title, :author, :description
Expand Down Expand Up @@ -659,7 +659,7 @@ With [**DelayedJob**](https://github.com/collectiveidea/delayed_job):

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch enqueue: :trigger_delayed_job do
attribute :title, :author, :description
Expand All @@ -683,7 +683,7 @@ Extend a change to a related record.

```ruby
class Author < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

has_many :books
# If your association uses belongs_to
Expand All @@ -693,7 +693,7 @@ class Author < ActiveRecord::Base
end

class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

belongs_to :author
after_touch :index!
Expand All @@ -712,7 +712,7 @@ With **Sequel**, you can use the `touch` plugin to propagate changes.
```ruby
# app/models/author.rb
class Author < Sequel::Model
include MeiliSearch::Rails
include Meilisearch::Rails

one_to_many :books

Expand All @@ -734,7 +734,7 @@ end

# app/models/book.rb
class Book < Sequel::Model
include MeiliSearch::Rails
include Meilisearch::Rails

many_to_one :author
after_touch :index!
Expand All @@ -757,7 +757,7 @@ You can strip all HTML tags from your attributes with the `sanitize` option.

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch sanitize: true
end
Expand All @@ -769,7 +769,7 @@ You can force the UTF-8 encoding of all your attributes using the `force_utf8_en

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch force_utf8_encoding: true
end
Expand All @@ -781,7 +781,7 @@ You can eager load associations using `meilisearch_import` scope.

```ruby
class Author < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

has_many :books

Expand Down Expand Up @@ -834,7 +834,7 @@ You can disable exceptions that could be raised while trying to reach Meilisearc

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

# Only raise exceptions in development environment.
meilisearch raise_on_failure: Rails.env.development?
Expand All @@ -849,7 +849,7 @@ You can force indexing and removing to be synchronous by setting the following o

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch synchronous: true
end
Expand All @@ -862,7 +862,7 @@ You can disable auto-indexing and auto-removing setting the following options:

```ruby
class Book < ActiveRecord::Base
include MeiliSearch::Rails
include Meilisearch::Rails

meilisearch auto_index: false, auto_remove: false
end
Expand Down
Loading
Loading