You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for [JSON]({{< relref "/develop/data-types/json" >}}) data and
21
-
run queries against the index.
20
+
for [JSON]({{< relref "/develop/data-types/json" >}}) documents and
21
+
run queries against the index. It then goes on to show the slight differences
22
+
in the equivalent code for [hash]({{< relref "/develop/data-types/hashes" >}})
23
+
documents.
22
24
23
-
Make sure that you have Redis Community Edition and `redis-py` installed.
25
+
## Initialize
24
26
25
-
Import dependencies:
27
+
Make sure that you have [Redis Community Edition]({{< relref "/operate/oss_and_stack/" >}})
28
+
or another Redis server available. Also install the
29
+
[`redis-py`]({{< relref "/develop/clients/redis-py" >}}) client library if you
30
+
haven't already done so.
31
+
32
+
Add the following dependencies. All of them are applicable to both JSON and hash,
33
+
except for the `Path` class, which is specific to JSON (see
34
+
[Path]({{< relref "/develop/data-types/json/path" >}}) for a description of the
35
+
JSON path syntax).
26
36
27
37
{{< clients-example py_home_json import >}}
28
38
{{< /clients-example >}}
29
39
30
-
Connect to your Redis database.
40
+
## Create data
31
41
32
-
{{< clients-example py_home_json connect >}}
42
+
Create some test data to add to your database. The example data shown
43
+
below is compatible with both JSON and hash objects.
44
+
45
+
{{< clients-example py_home_json create_data >}}
33
46
{{< /clients-example >}}
34
47
35
-
Create some test data to add to your database.
48
+
## Add the index
36
49
37
-
{{< clients-example py_home_json create_data >}}
50
+
Connect to your Redis database. The code below shows the most
51
+
basic connection but see
52
+
[Connect to the server]({{< relref "/develop/clients/redis-py/connect" >}})
53
+
to learn more about the available connection options.
54
+
55
+
{{< clients-example py_home_json connect >}}
38
56
{{< /clients-example >}}
39
57
40
-
Create an index. In this example, only JSON documents with the key prefix `user:` are indexed. For more information, see [Query syntax]({{< relref "/develop/interact/search-and-query/query/" >}}).
58
+
Create an index for the JSON data. The code below specifies that only JSON documents with
59
+
the key prefix `user:` are indexed. For more information, see
0 commit comments