File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,32 @@ func ExampleClient_search_json() {
152152 // >>> Tel Aviv
153153 // STEP_END
154154
155+ // STEP_START query2count_only
156+ citiesResult2 , err := rdb .FTSearchWithArgs (
157+ ctx ,
158+ "idx:users" ,
159+ "Paul" ,
160+ & redis.FTSearchOptions {
161+ Return : []redis.FTSearchReturn {
162+ {
163+ FieldName : "$.city" ,
164+ As : "city" ,
165+ },
166+ },
167+ CountOnly : true ,
168+ },
169+ ).Result ()
170+
171+ if err != nil {
172+ panic (err )
173+ }
174+
175+ // The `Total` field has the correct number of docs found
176+ // by the query but the `Docs` slice is empty.
177+ fmt .Println (len (citiesResult2 .Docs )) // >>> 0
178+ fmt .Println (citiesResult2 .Total ) // >>> 2
179+ // STEP_END
180+
155181 // STEP_START query3
156182 aggOptions := redis.FTAggregateOptions {
157183 GroupBy : []redis.FTAggregateGroupBy {
@@ -196,6 +222,8 @@ func ExampleClient_search_json() {
196222 // {1 [{user:3 <nil> <nil> <nil> map[$:{"age":35,"city":"Tel Aviv","email":"[email protected] ","name":"Paul Zamir"}]}]} 197223 // London
198224 // Tel Aviv
225+ // 0
226+ // 2
199227 // London - 1
200228 // Tel Aviv - 2
201229}
You can’t perform that action at this time.
0 commit comments