Skip to content

Commit c719394

Browse files
authored
Fixing index creation: CASESENSITIVE preceeds SORTABLE (RediSearch#173)
* Change Tag Field Options Order
1 parent c049342 commit c719394

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

redisearch/client_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,8 @@ func TestClient_InfoFieldsTest(t *testing.T) {
12271227
AddField(NewGeoField("geo")).
12281228
AddField(NewNumericField("numeric")).
12291229
AddField(NewTextFieldOptions("alias_type", TextFieldOptions{As: "type", Sortable: true, NoIndex: true, NoStem: true})).
1230-
AddField(NewTagFieldOptions("address_city", TagFieldOptions{As: "city"}))
1230+
AddField(NewTagFieldOptions("address_city", TagFieldOptions{As: "city"})).
1231+
AddField(NewTagFieldOptions("type", TagFieldOptions{As: "tag", Sortable: true, CaseSensitive: true, NoIndex: true}))
12311232
// In this example we will only index keys started by product:
12321233
indexDefinition := NewIndexDefinition().AddPrefix("ft-info-fields-test:")
12331234
// Add the Index Definition
@@ -1245,6 +1246,7 @@ func TestClient_InfoFieldsTest(t *testing.T) {
12451246
Field{Name: "numeric", Type: 1, Sortable: false, Options: NumericFieldOptions{Sortable: false, NoIndex: false, As: "numeric"}},
12461247
Field{Name: "alias_type", Type: 0, Sortable: true, Options: TextFieldOptions{Weight: 1, Sortable: true, NoStem: true, NoIndex: true, PhoneticMatcher: "", As: "type"}},
12471248
Field{Name: "address_city", Type: 3, Sortable: false, Options: TagFieldOptions{Separator: 44, NoIndex: false, Sortable: false, CaseSensitive: false, As: "city"}},
1249+
Field{Name: "type", Type: 3, Sortable: true, Options: TagFieldOptions{Separator: 44, NoIndex: true, Sortable: true, CaseSensitive: true, As: "tag"}},
12481250
}),
12491251
info.Schema.Fields)
12501252
}

redisearch/schema.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ func serializeField(f Field, args redis.Args) (argsOut redis.Args, err error) {
422422
if opts.Separator != 0 {
423423
argsOut = append(argsOut, "SEPARATOR", fmt.Sprintf("%c", opts.Separator))
424424
}
425+
if opts.CaseSensitive {
426+
argsOut = append(argsOut, "CASESENSITIVE")
427+
}
425428
if opts.Sortable {
426429
argsOut = append(argsOut, "SORTABLE")
427430
}
428431
if opts.NoIndex {
429432
argsOut = append(argsOut, "NOINDEX")
430433
}
431-
if opts.CaseSensitive {
432-
argsOut = append(argsOut, "CASESENSITIVE")
433-
}
434434
}
435435
case GeoField:
436436
argsOut = append(argsOut, f.Name, "GEO")

0 commit comments

Comments
 (0)