Skip to content

Commit 3ac7334

Browse files
authored
Merge branch 'main' into change-indexes-method
2 parents ccbe912 + e5a7c96 commit 3ac7334

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ require 'meilisearch'
7878
client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
7979

8080
# An index is where the documents are stored.
81-
index = client.index('books')
81+
index = client.index('movies')
8282

8383
documents = [
84-
{ book_id: 123, title: 'Pride and Prejudice' },
85-
{ book_id: 456, title: 'Le Petit Prince' },
86-
{ book_id: 1, title: 'Alice In Wonderland' },
87-
{ book_id: 1344, title: 'The Hobbit' },
88-
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince' },
89-
{ book_id: 42, title: 'The Hitchhiker\'s Guide to the Galaxy' }
84+
{ id: 1, title: 'Carol', genres: ['Romance', 'Drama'] },
85+
{ id: 2, title: 'Wonder Woman', genres: ['Action', 'Adventure'] },
86+
{ id: 3, title: 'Life of Pi', genres: ['Adventure', 'Drama'] },
87+
{ id: 4, title: 'Mad Max: Fury Road', genres: ['Adventure', 'Science Fiction'] },
88+
{ id: 5, title: 'Moana', genres: ['Fantasy', 'Action']},
89+
{ id: 6, title: 'Philadelphia', genres: ['Drama'] },
9090
]
91-
# If the index 'books' does not exist, MeiliSearch creates it when you first add the documents.
91+
# If the index 'movies' does not exist, MeiliSearch creates it when you first add the documents.
9292
index.add_documents(documents) # => { "updateId": 0 }
9393
```
9494

@@ -100,20 +100,20 @@ With the `updateId`, you can check the status (`enqueued`, `processing`, `proces
100100

101101
``` ruby
102102
# MeiliSearch is typo-tolerant:
103-
puts index.search('harry pottre')
103+
puts index.search('carlo')
104104
```
105105
Output:
106106

107107
```ruby
108108
{
109109
"hits" => [{
110-
"book_id" => 4,
111-
"title" => "Harry Potter and the Half-Blood Prince"
110+
"id" => 1,
111+
"title" => "Carol"
112112
}],
113113
"offset" => 0,
114114
"limit" => 20,
115115
"processingTimeMs" => 1,
116-
"query" => "harry pottre"
116+
"query" => "carlo"
117117
}
118118
```
119119

@@ -123,7 +123,7 @@ All the supported options are described in the [search parameters](https://docs.
123123

124124
```ruby
125125
index.search(
126-
'hob',
126+
'wonder',
127127
attributesToHighlight: ['*']
128128
)
129129
```
@@ -134,18 +134,18 @@ JSON output:
134134
{
135135
"hits": [
136136
{
137-
"book_id": 1344,
138-
"title": "The Hobbit",
137+
"id": 2,
138+
"title": "Wonder Woman",
139139
"_formatted": {
140-
"book_id": 1344,
141-
"title": "The <em>Hob</em>bit"
140+
"id": 2,
141+
"title": "<em>Wonder</em> Woman"
142142
}
143143
}
144144
],
145145
"offset": 0,
146146
"limit": 20,
147147
"processingTimeMs": 0,
148-
"query": "hob"
148+
"query": "wonder"
149149
}
150150
```
151151

0 commit comments

Comments
 (0)