Skip to content

Commit

Permalink
Fixing index creation: CASESENSITIVE preceeds SORTABLE (#173)
Browse files Browse the repository at this point in the history
* Change Tag Field Options Order
  • Loading branch information
Avital-Fine authored Sep 1, 2022
1 parent c049342 commit c719394
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion redisearch/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,8 @@ func TestClient_InfoFieldsTest(t *testing.T) {
AddField(NewGeoField("geo")).
AddField(NewNumericField("numeric")).
AddField(NewTextFieldOptions("alias_type", TextFieldOptions{As: "type", Sortable: true, NoIndex: true, NoStem: true})).
AddField(NewTagFieldOptions("address_city", TagFieldOptions{As: "city"}))
AddField(NewTagFieldOptions("address_city", TagFieldOptions{As: "city"})).
AddField(NewTagFieldOptions("type", TagFieldOptions{As: "tag", Sortable: true, CaseSensitive: true, NoIndex: true}))
// In this example we will only index keys started by product:
indexDefinition := NewIndexDefinition().AddPrefix("ft-info-fields-test:")
// Add the Index Definition
Expand All @@ -1245,6 +1246,7 @@ func TestClient_InfoFieldsTest(t *testing.T) {
Field{Name: "numeric", Type: 1, Sortable: false, Options: NumericFieldOptions{Sortable: false, NoIndex: false, As: "numeric"}},
Field{Name: "alias_type", Type: 0, Sortable: true, Options: TextFieldOptions{Weight: 1, Sortable: true, NoStem: true, NoIndex: true, PhoneticMatcher: "", As: "type"}},
Field{Name: "address_city", Type: 3, Sortable: false, Options: TagFieldOptions{Separator: 44, NoIndex: false, Sortable: false, CaseSensitive: false, As: "city"}},
Field{Name: "type", Type: 3, Sortable: true, Options: TagFieldOptions{Separator: 44, NoIndex: true, Sortable: true, CaseSensitive: true, As: "tag"}},
}),
info.Schema.Fields)
}
6 changes: 3 additions & 3 deletions redisearch/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ func serializeField(f Field, args redis.Args) (argsOut redis.Args, err error) {
if opts.Separator != 0 {
argsOut = append(argsOut, "SEPARATOR", fmt.Sprintf("%c", opts.Separator))
}
if opts.CaseSensitive {
argsOut = append(argsOut, "CASESENSITIVE")
}
if opts.Sortable {
argsOut = append(argsOut, "SORTABLE")
}
if opts.NoIndex {
argsOut = append(argsOut, "NOINDEX")
}
if opts.CaseSensitive {
argsOut = append(argsOut, "CASESENSITIVE")
}
}
case GeoField:
argsOut = append(argsOut, f.Name, "GEO")
Expand Down

0 comments on commit c719394

Please sign in to comment.