Skip to content

Commit 37b961c

Browse files
uglidechayim
andauthored
Use explicit index name in RediSearch example (#2466)
Co-authored-by: Igor Malinovskiy <igor.malinovskiy@redis.com> Co-authored-by: Chayim I. Kirshen <c@kirshen.com>
1 parent a114f26 commit 37b961c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/redismodules.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ These are the commands for interacting with the `RedisBloom module <https://redi
1212
**Create and add to a bloom filter**
1313

1414
.. code-block:: python
15-
16-
import redis
15+
16+
import redis
1717
r = redis.Redis()
18-
r.bf().create("bloom", 0.01, 1000)
18+
r.bf().create("bloom", 0.01, 1000)
1919
r.bf().add("bloom", "foo")
2020
2121
**Create and add to a cuckoo filter**
2222

2323
.. code-block:: python
2424
25-
import redis
25+
import redis
2626
r = redis.Redis()
2727
r.cf().create("cuckoo", 1000)
2828
r.cf().add("cuckoo", "filter")
@@ -107,7 +107,8 @@ Examples of how to combine search and json can be found `here <examples/search_j
107107
RediSearch Commands
108108
*******************
109109
110-
These are the commands for interacting with the `RediSearch module <https://redisearch.io>`_. Below is a brief example, as well as documentation on the commands themselves.
110+
These are the commands for interacting with the `RediSearch module <https://redisearch.io>`_. Below is a brief example, as well as documentation on the commands themselves. In the example
111+
below, an index named *my_index* is being created. When an index name is not specified, an index named *idx* is created.
111112
112113
**Create a search index, and display its information**
113114
@@ -117,8 +118,9 @@ These are the commands for interacting with the `RediSearch module <https://redi
117118
from redis.commands.search.field import TextField
118119
119120
r = redis.Redis()
120-
r.ft().create_index(TextField("play", weight=5.0), TextField("ball"))
121-
print(r.ft().info())
121+
index_name = "my_index"
122+
r.ft(index_name).create_index(TextField("play", weight=5.0), TextField("ball"))
123+
print(r.ft(index_name).info())
122124
123125
124126
.. automodule:: redis.commands.search.commands

0 commit comments

Comments
 (0)