From dc5605bc9a4d2308628209aec2f078e2f597df48 Mon Sep 17 00:00:00 2001 From: Itamar Haber Date: Mon, 27 Feb 2023 16:14:24 +0200 Subject: Edits example --- docs/examples/json_search/example.json | 9 +-------- 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") -- cgit v1.2.1