summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Malinovskiy <u.glide@gmail.com>2022-12-04 09:04:53 +0100
committerGitHub <noreply@github.com>2022-12-04 10:04:53 +0200
commit37b961cedbfa264737e645e4c9343724a412b1bc (patch)
treebef61dcc3e0f9d7dd087db5d55028e7602d15794
parenta114f26c03aa9127826cf39c60c759340f93653b (diff)
downloadredis-py-37b961cedbfa264737e645e4c9343724a412b1bc.tar.gz
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>
-rw-r--r--docs/redismodules.rst16
1 files changed, 9 insertions, 7 deletions
diff --git a/docs/redismodules.rst b/docs/redismodules.rst
index f764d82..2b0b3c6 100644
--- a/docs/redismodules.rst
+++ b/docs/redismodules.rst
@@ -12,17 +12,17 @@ These are the commands for interacting with the `RedisBloom module <https://redi
**Create and add to a bloom filter**
.. code-block:: python
-
- import redis
+
+ import redis
r = redis.Redis()
- r.bf().create("bloom", 0.01, 1000)
+ r.bf().create("bloom", 0.01, 1000)
r.bf().add("bloom", "foo")
**Create and add to a cuckoo filter**
.. code-block:: python
- import redis
+ import redis
r = redis.Redis()
r.cf().create("cuckoo", 1000)
r.cf().add("cuckoo", "filter")
@@ -107,7 +107,8 @@ Examples of how to combine search and json can be found `here <examples/search_j
RediSearch Commands
*******************
-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.
+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
+below, an index named *my_index* is being created. When an index name is not specified, an index named *idx* is created.
**Create a search index, and display its information**
@@ -117,8 +118,9 @@ These are the commands for interacting with the `RediSearch module <https://redi
from redis.commands.search.field import TextField
r = redis.Redis()
- r.ft().create_index(TextField("play", weight=5.0), TextField("ball"))
- print(r.ft().info())
+ index_name = "my_index"
+ r.ft(index_name).create_index(TextField("play", weight=5.0), TextField("ball"))
+ print(r.ft(index_name).info())
.. automodule:: redis.commands.search.commands