@@ -116,5 +116,39 @@ to count all users in each city.
116
116
{{< clients-example go_home_json query3 >}}
117
117
{{< /clients-example >}}
118
118
119
+ ## Differences with hash documents
120
+
121
+ Indexing for hash documents is very similar to JSON indexing but you
122
+ need to specify some slightly different options.
123
+
124
+ When you create the schema for a hash index, you don't need to
125
+ add aliases for the fields, since you use the basic names to access
126
+ the fields anyway. Also, you must use ` HASH ` for the ` IndexType `
127
+ when you create the index. The code below shows these changes with
128
+ a new index called ` hash-idx:users ` , which is otherwise the same as
129
+ the ` idx:users ` index used for JSON documents in the previous examples.
130
+
131
+ {{< clients-example go_home_json make_hash_index >}}
132
+ {{< /clients-example >}}
133
+
134
+ You use [ ` HSet() ` ] ({{< relref "/commands/hset" >}}) to add the hash
135
+ documents instead of [ ` JSONSet() ` ] ({{< relref "/commands/json.set" >}}),
136
+ but the same flat ` userX ` maps work equally well with either
137
+ hash or JSON:
138
+
139
+ {{< clients-example go_home_json add_hash_data >}}
140
+ {{< /clients-example >}}
141
+
142
+ The query commands work the same here for hash as they do for JSON (but
143
+ the name of the hash index is different). The format of the result is
144
+ also almost the same except that the fields are returned directly in the
145
+ result ` Document ` object map instead of in an enclosing ` json ` string
146
+ under the key "$":
147
+
148
+ {{< clients-example go_home_json query1_hash >}}
149
+ {{< /clients-example >}}
150
+
151
+ ## More information
152
+
119
153
See the [ Redis query engine] ({{< relref "/develop/interact/search-and-query" >}}) docs
120
- for a full description of all query features with examples.
154
+ for a full description of all query features with examples.
0 commit comments