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
Define indexed fields and their data types using `schema`. Use JSON path expressions to map specific JSON elements to the schema fields.
67
-
68
-
```python
69
-
schema = (
70
-
TextField("$.name", as_name="name"),
71
-
TagField("$.city", as_name="city"),
72
-
NumericField("$.age", as_name="age")
73
-
)
74
-
```
75
-
76
-
Create an index. In this example, all JSON documents with the key prefix `user:` will be indexed. For more information, see [Query syntax]({{< relref "/develop/interact/search-and-query/query/" >}}).
77
-
78
-
```python
79
-
rs = r.ft("idx:users")
80
-
rs.create_index(
81
-
schema,
82
-
definition=IndexDefinition(
83
-
prefix=["user:"], index_type=IndexType.JSON
84
-
)
85
-
)
86
-
# b'OK'
87
-
```
88
-
89
-
Use [`JSON.SET`]({{< baseurl >}}/commands/json.set/) to set each user value at the specified path.
90
-
91
-
```python
92
-
r.json().set("user:1", Path.root_path(), user1)
93
-
r.json().set("user:2", Path.root_path(), user2)
94
-
r.json().set("user:3", Path.root_path(), user3)
95
-
```
96
-
97
-
Let's find user `Paul` and filter the results by age.
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/" >}}).
41
+
42
+
{{< clients-example py_home_json make_index >}}
43
+
{{< /clients-example >}}
44
+
45
+
Add the three sets of user data to the database as
0 commit comments