Skip to content

Commit 2fe60dd

Browse files
committed
update documentation
1 parent 1b00290 commit 2fe60dd

File tree

5 files changed

+43
-28
lines changed

5 files changed

+43
-28
lines changed

docs/003-create-index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ This is where RediSearch module is helping, and why it as been created.
8585

8686
RediSearch simplifies a lot this by offering a simple and automatic way to create secondary indices on Redis Hashes. (more datastructure will eventually come)
8787

88-
![Secondary Index](https://github.com/Redis-Developer/getting-started-redisearch/blob/master/docs/images/secondary-index.png)
88+
![Secondary Index](https://raw.githubusercontent.com/RediSearch/redisearch-getting-started/blob/master/docs/images/secondary-index.png)
8989

9090
Using RediSearch if you want to query on a field, you must index the fields. Let's start by indexing the following fields in of our movies:
9191

@@ -117,7 +117,7 @@ Before running some queries let's look at the command in detail:
117117
* `idx:movie` : the name of the index
118118
* `ON hash` : the type of structure to be indexed. *Note that in RediSearch 2.0 only hash structure are supported, this is parameter will allow RediSearch to index other structure in the future*
119119
* `PREFIX 1 "movie:"` : the prefix of the keys that should be indexed. This is a list, so since we want to only index movie:* keys the number is 1. Suppose you want to index movies and tv_show that have the same fields, you can use: `PREFIX 2 "movie:" "tv_show:"`
120-
* `SCHEMA ...`: define the schema, the fields and their type, to index, as you can see in the command, we are using TEXT, NUMERIC and TAG, and SORTABLE parameters.
120+
* `SCHEMA ...`: define the schema, the fields and their type, to index, as you can see in the command, we are using [TEXT](https://oss.redislabs.com/redisearch/Query_Syntax/#a_few_query_examples), [NUMERIC](https://oss.redislabs.com/redisearch/Query_Syntax/#numeric_filters_in_query) and [TAG](https://oss.redislabs.com/redisearch/Query_Syntax/#tag_filters), and [SORTABLE](https://oss.redislabs.com/redisearch/Sorting/) parameters.
121121

122122
You can find information about the [FT.CREATE](https://oss.redislabs.com/redisearch/Commands/#ftcreate) command in the [documentation](https://oss.redislabs.com/redisearch/Commands/#ftcreate).
123123

docs/004-query-data.md

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ The database contains few movies, and an index, it is not possible to execute so
44

55
## Queries
66

7-
**Example : *All the movies that contains the string "`star`"***
7+
**Example : *All the movies that contains the string "`war`"***
88

99
```
10-
> FT.SEARCH idx:movie "star"
10+
> FT.SEARCH idx:movie "war"
1111
1212
1) (integer) 2
1313
2) "movie:11005"
@@ -26,14 +26,14 @@ The database contains few movies, and an index, it is not possible to execute so
2626

2727
The FT.SEARCH commands returns the list of result starting with the number of results, then the list of elements (keys & fields).
2828

29-
This example uses a simple query string `"star"`, this will return all the movies that *contain* the word star in a text field of the index.
29+
As you can see the movie *Star Wars: Episode V - The Empire Strikes Back* is found, even though you used only the word “war” to match “Wars” in the title. This is because the title has been indexed as text, so the field is [tokenized](https://oss.redislabs.com/redisearch/Escaping/) and [stemmed](https://oss.redislabs.com/redisearch/Stemming/).
3030

3131
Later when looking in more details on the query syntax you will learn more the search capabilities.
3232

3333
It is also possible to limit the list of fields returned by the query using the `RETURN` parameter, let's run the same query, and return only the title and release_year:
3434

3535
```
36-
> FT.SEARCH idx:movie "star" RETURN 2 title release_year
36+
> FT.SEARCH idx:movie "war" RETURN 2 title release_year
3737
3838
1) (integer) 2
3939
2) "movie:11005"
@@ -53,17 +53,16 @@ This query does not specific any "field" and still return some movie, this is be
5353
If you need to do a query on a specific field you can specify it using the `@field:` syntax, for example:
5454

5555
```
56-
> FT.SEARCH idx:movie "@title:star" RETURN 2 title release_year
56+
> FT.SEARCH idx:movie "@title:war" RETURN 2 title release_year
5757
```
5858

59-
6059
---
61-
**Example : *All the movies that contains the string "`star` but NOT the `jedi` one"***
60+
**Example : *All the movies that contains the string "`war` but NOT the `jedi` one"***
6261

6362
Adding the string `-jedi` (minus) will ask the query engine to not return the values that contain `jedi`.
6463

6564
```
66-
> FT.SEARCH idx:movie "star -jedi" RETURN 2 title release_year
65+
> FT.SEARCH idx:movie "war -jedi" RETURN 2 title release_year
6766
6867
1) (integer) 1
6968
2) "movie:11002"
@@ -73,6 +72,21 @@ Adding the string `-jedi` (minus) will ask the query engine to not return the va
7372
4) "1980"
7473
```
7574

75+
---
76+
**Example : *All the movies that contains the string "`gdfather` using fuzzy search"***
77+
78+
As you can see the word godfather is wrongly spelled, it is possible using a [fuzzy matching](https://oss.redislabs.com/redisearch/Query_Syntax/#fuzzy_matching). Fuzzy matches are performed based on [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) (LD).
79+
80+
```
81+
> FT.SEARCH idx:movie " %gdfather% " RETURN 2 title release_year
82+
83+
1) (integer) 1
84+
2) "movie:11003"
85+
3) 1) "title"
86+
2) "The Godfather"
87+
3) "release_year"
88+
4) "1972"
89+
```
7690

7791
---
7892
**Example : *All `Thriller` movies"***
@@ -93,7 +107,6 @@ The syntax to query a TAG field is @field_name:{value}
93107
94108
```
95109

96-
97110
---
98111
**Example : *All `Thriller` or `Action` movies"***
99112

@@ -153,7 +166,9 @@ or
153166

154167
```
155168
> FT.SEARCH idx:movie * FILTER release_year 1970 1980 RETURN 2 title release_year
169+
```
156170

171+
```
157172
> FT.SEARCH idx:movie "@release_year:[1970 1980]" RETURN 2 title release_year
158173
159174
1) (integer) 2
@@ -176,7 +191,6 @@ To exclude a value prepend it with `(` in the FILTER or query string, for exampl
176191
> FT.SEARCH idx:movie "@release_year:[1970 (1980]" RETURN 2 title release_year
177192
```
178193

179-
180194
---
181195
## Insert, Update, Delete and Expire Documents
182196

@@ -188,25 +202,25 @@ As part of this tutorial you have:
188202

189203
When creating the index, using the `idx:movie ON hash PREFIX 1 "movie:"` parameter you are asking the indexing engine to look at all existing keys and index them.
190204

191-
Also any new information that match this pattern/type, will be indexed.
205+
Also new information that match this pattern/type, will be indexed.
192206

193-
Let's count the number of movie and then add a new one, and count again:
207+
Let's count the number of movies, add a new one, and count again:
194208

195209
```
196210
> FT.SEARCH idx:movie "*" LIMIT 0 0
211+
197212
1) (integer) 4
198213
199214
200215
> HSET movie:11033 title "Tomorrow Never Dies" plot "James Bond sets out to stop a media mogul's plan to induce war between China and the U.K in order to obtain exclusive global media coverage." release_year 1997 genre "Action" rating 6.5 votes 177732 imdb_id tt0120347
201216
202217
> FT.SEARCH idx:movie "*" LIMIT 0 0
218+
203219
1) (integer) 5
204220
205221
```
206222

207-
The new movie has been indexed.
208-
209-
You can also search on any of the indexed fields:
223+
The new movie has been indexed. You can also search on any of the indexed fields:
210224

211225
```
212226
> FT.SEARCH idx:movie "never" RETURN 2 title release_year
@@ -219,7 +233,7 @@ You can also search on any of the indexed fields:
219233
4) "1997"
220234
```
221235

222-
Let **update** one of the field, and search for `007`
236+
Now you **update** one of the field, and search for `007`
223237

224238
```
225239
> HSET movie:11033 title "Tomorrow Never Dies - 007"
@@ -235,7 +249,7 @@ Let **update** one of the field, and search for `007`
235249
4) "1997"
236250
```
237251

238-
When you *delete* the has the index is also updated, and the same happends when you are using expiration (TTL-Time To Live).
252+
When you *delete* the hash, the index is also updated, and the same happens the the key is expired (TTL-Time To Live).
239253

240254
For example put a 20 sedonds expiration time to the James Bond movie:
241255

@@ -253,7 +267,7 @@ You can run the following query, and you will see after 20 seconds the document
253267
254268
```
255269

256-
> Note: When you are using Redis as your primary database you are not necessary using the TTL to delet record. However, if the data your are storing and indexing are transient, for example a caching layer at the top of another datastore or Web service, query user sessions content, ... This is often qualified as a "Ephemeral Search" use case: lighweight, fast and expiration.
270+
> Note: When you are using Redis as your primary database you are not necessary using the TTL to delet record. However, if the data your are storing and indexing are transient, for example a caching layer at the top of another datastore or Web service, query user sessions content, ... This is often qualified as a "[Ephemeral Search](https://redislabs.com/blog/the-case-for-ephemeral-search/)" use case: lighweight, fast and expiration.
257271
258272
---
259273
## More

docs/006-import-dataset.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ The theater hashes contain the following fields.
156156

157157
## Importing the Movies & Theaters
158158

159-
Before importing the data, you can start by flushing your project database:
159+
Before importing the data, flush the database:
160160

161161
```
162162
> FLUSHALL

docs/007-query-movies.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ TAG is the structure to use when you want to do exact match condition on string/
211211
</b></i>
212212
</summary>
213213

214-
This is very similar to the previous query, you can pass a list of value with the `|` to represent the OR.
214+
This is similar to the previous query, you can pass a list of value with the `|` to represent the OR.
215215

216216

217217
```
@@ -289,9 +289,9 @@ In this query it will be twao condition with a OR (`|`).
289289

290290
Summary
291291

292-
* A fieldless query will apply to all TEXT fields and will use the words and their base form (stemming)
292+
* Fieldless queries apply to all TEXT fields and use the words and their base form (stemming)
293293
* To apply a condition to a specific field you must use the `@field:` notation
294-
* Multiple conditions are "intersection" (AND condition)
294+
* Multiple conditions are "intersection" (AND condition), to do an "union" (OR condition), you have to use the "`|`" character.
295295

296296
----
297297
### Sort
@@ -319,18 +319,19 @@ A very common use case when querying data is to sort the data on a specific fiel
319319
4) "Mechanic: Resurrection"
320320
```
321321

322-
The first line contains the number of documents (`186`) that matche the query condition, the the list of movies.
322+
The first line contains the number of documents (`186`) that match the query condition.
323323

324-
The FT.SEARCH command by default returns the first 10 documents, you will see in the next query how to paginate.
324+
The FT.SEARCH command, by default, returns the first ten documents. You will see in the next query how to paginate.
325325

326+
You can only use one SORTBY in an FT.SEARCH query, if you want to sort on multiple fields, for example sorting movies by `genre` ascending and `release_year` descending, you have to use an FT.AGGREGATE, this is covered in the [next section](008-aggregation.md).
326327

328+
Note: The field used in the [SORTBY](https://oss.redislabs.com/redisearch/Sorting/#specifying_sortby) should be part of the index schema and defined as SORTABLE.
327329
---
328330
</details>
329331

330332
----
331333
### Paginate
332334

333-
334335
<details>
335336
<summary>
336337
<i><b>Query all the `Action` movies, sorted by release year from the oldest to the most recent one, returning the record by batch of 100 movies</b></i>

docs/009-application-development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can find the same REST Service that uses RediSearch developed with different
1212

1313
The frontend is created using a Vue.js application that let you run search queries using each of the REST backend.
1414

15-
![Application Architecture](https://github.com/Redis-Developer/getting-started-redisearch/blob/master/docs/images/sample-app-archi.png)
15+
![Application Architecture](https://raw.githubusercontent.com/RediSearch/redisearch-getting-started/master/docs/images/sample-app-archi.png)
1616

1717

1818
## Run the Sample Application

0 commit comments

Comments
 (0)