diff options
author | Itamar Haber <itamar@redis.com> | 2023-02-27 16:14:24 +0200 |
---|---|---|
committer | Itamar Haber <itamar@redis.com> | 2023-02-27 16:14:24 +0200 |
commit | dc5605bc9a4d2308628209aec2f078e2f597df48 (patch) | |
tree | 2f4028728bdf71482171178c6ab3c0484f241106 | |
parent | 4375f271a067908d513c25750e13bdefb2219b42 (diff) | |
download | redis-py-dc5605bc9a4d2308628209aec2f078e2f597df48.tar.gz |
Edits example
-rw-r--r-- | docs/examples/json_search/example.json | 9 | ||||
-rw-r--r-- | docs/examples/json_search/main.py | 15 |
2 files changed, 3 insertions, 21 deletions
diff --git a/docs/examples/json_search/example.json b/docs/examples/json_search/example.json index d26848e..835782a 100644 --- a/docs/examples/json_search/example.json +++ b/docs/examples/json_search/example.json @@ -1,11 +1,4 @@ { "id": "json_search", - "file": "main.py", - "highlight": [ - "37-41", - "43-45", - "47" - ], - "hide": [], - "collapse": [] + "file": "main.py" } diff --git a/docs/examples/json_search/main.py b/docs/examples/json_search/main.py index 44551a9..409592f 100644 --- a/docs/examples/json_search/main.py +++ b/docs/examples/json_search/main.py @@ -1,8 +1,9 @@ +# HIDE_START import redis from redis.commands.json.path import Path from redis.commands.search.field import TextField, NumericField, TagField from redis.commands.search.indexDefinition import IndexDefinition, IndexType - +# HIDE_END r = redis.Redis(host='localhost', port=6379) user1 = { @@ -33,15 +34,3 @@ user3 = { r.json().set("user:1", Path.root_path(), user1) r.json().set("user:2", Path.root_path(), user2) r.json().set("user:3", Path.root_path(), user3) - -schema = ( - TextField("$.user.name", as_name="name"), - TagField("$.user.city", as_name="city"), - NumericField("$.user.age", as_name="age") -) - -r.ft().create_index(schema, definition= - IndexDefinition(prefix=["user:"], index_type=IndexType.JSON) -) - -r.ft().search("Paul") |