Skip to content

Commit 116870d

Browse files
authored
Merge branch 'master' into 181-nil-document-check-on-load
2 parents c77eed5 + c719394 commit 116870d

File tree

11 files changed

+71
-29
lines changed

11 files changed

+71
-29
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
branches:
1616
- master
1717
- '[0-9].[0-9]'
18+
schedule:
19+
- cron: "5 1 * * *"
1820

1921
jobs:
2022

examples/redisearch_auth/redisearch_auth.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/RediSearch/redisearch-go/redisearch"
6-
"github.com/gomodule/redigo/redis"
75
"log"
86
"time"
7+
8+
"github.com/RediSearch/redisearch-go/v2/redisearch"
9+
"github.com/gomodule/redigo/redis"
910
)
1011

1112
// exemplifies the NewClientFromPool function

examples/redisearch_geo/redisearch_geo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/RediSearch/redisearch-go/redisearch"
65
"log"
6+
7+
"github.com/RediSearch/redisearch-go/v2/redisearch"
78
)
89

910
/**

examples/redisearch_quickstart/redisearch_quickstart.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/RediSearch/redisearch-go/redisearch"
65
"log"
76
"time"
7+
8+
"github.com/RediSearch/redisearch-go/v2/redisearch"
89
)
910

1011
/**

examples/redisearch_temporary_index/redisearch_temporary_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"time"
77

8-
"github.com/RediSearch/redisearch-go/redisearch"
8+
"github.com/RediSearch/redisearch-go/v2/redisearch"
99
)
1010

1111
/**

examples/redisearch_tls_client/redisearch_tls_client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"crypto/x509"
66
"flag"
77
"fmt"
8-
"github.com/RediSearch/redisearch-go/redisearch"
9-
"github.com/gomodule/redigo/redis"
108
"io/ioutil"
119
"log"
1210
"os"
1311
"time"
12+
13+
"github.com/RediSearch/redisearch-go/v2/redisearch"
14+
"github.com/gomodule/redigo/redis"
1415
)
1516

1617
var (

redisearch/client.go

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -523,26 +523,59 @@ func (info *IndexInfo) loadSchema(values []interface{}, options []string) {
523523
}
524524

525525
f := Field{Name: spec[sliceIndex(spec, "identifier")+1]}
526-
switch strings.ToUpper(spec[sliceIndex(spec, "type")+1]) {
526+
switch strings.ToUpper(options[2]) {
527527
case "TAG":
528528
f.Type = TagField
529-
tfOptions := TagFieldOptions{}
529+
tfOptions := TagFieldOptions{
530+
As: options[0],
531+
}
532+
if sliceIndex(options, "NOINDEX") != -1 {
533+
tfOptions.NoIndex = true
534+
}
535+
if sliceIndex(options, "SORTABLE") != -1 {
536+
tfOptions.Sortable = true
537+
}
538+
if sliceIndex(options, "CASESENSITIVE") != -1 {
539+
tfOptions.CaseSensitive = true
540+
}
530541
if wIdx := sliceIndex(options, "SEPARATOR"); wIdx != -1 {
531542
tfOptions.Separator = options[wIdx+1][0]
532543
}
533544
f.Options = tfOptions
545+
f.Sortable = tfOptions.Sortable
534546
case "GEO":
535547
f.Type = GeoField
548+
gfOptions := GeoFieldOptions{
549+
As: options[0],
550+
}
551+
if sliceIndex(options, "NOINDEX") != -1 {
552+
gfOptions.NoIndex = true
553+
}
554+
f.Options = gfOptions
536555
case "NUMERIC":
537556
f.Type = NumericField
538-
nfOptions := NumericFieldOptions{}
557+
nfOptions := NumericFieldOptions{
558+
As: options[0],
559+
}
560+
if sliceIndex(options, "NOINDEX") != -1 {
561+
nfOptions.NoIndex = true
562+
}
539563
if sliceIndex(options, "SORTABLE") != -1 {
540564
nfOptions.Sortable = true
541565
}
542566
f.Options = nfOptions
567+
f.Sortable = nfOptions.Sortable
543568
case "TEXT":
544569
f.Type = TextField
545-
tfOptions := TextFieldOptions{}
570+
tfOptions := TextFieldOptions{
571+
As: options[0],
572+
}
573+
if sliceIndex(options, "NOSTEM") != -1 {
574+
tfOptions.NoStem = true
575+
}
576+
if sliceIndex(options, "NOINDEX") != -1 {
577+
tfOptions.NoIndex = true
578+
}
546579
if sliceIndex(options, "SORTABLE") != -1 {
547580
tfOptions.Sortable = true
548581
}
@@ -552,6 +585,7 @@ func (info *IndexInfo) loadSchema(values []interface{}, options []string) {
552585
tfOptions.Weight = float32(weight64)
553586
}
554587
f.Options = tfOptions
588+
f.Sortable = tfOptions.Sortable
555589
case "VECTOR":
556590
f.Type = VectorField
557591
f.Options = VectorFieldOptions{}
@@ -586,14 +620,8 @@ func (i *Client) Info() (*IndexInfo, error) {
586620
switch key {
587621
case "index_options":
588622
indexOptions, _ = redis.Strings(res[ii+1], nil)
589-
case "fields":
623+
case "fields", "attributes":
590624
schemaAttributes, _ = redis.Values(res[ii+1], nil)
591-
case "attributes":
592-
for _, attr := range res[ii+1].([]interface{}) {
593-
l := len(attr.([]interface{}))
594-
schemaAttributes = append(schemaAttributes, attr.([]interface{})[3:l])
595-
596-
}
597625
}
598626
}
599627

redisearch/client_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ func TestClient_InfoSchemaFields(t *testing.T) {
12031203
Options: NumericFieldOptions{
12041204
Sortable: false,
12051205
NoIndex: false,
1206-
As: "",
1206+
As: "age",
12071207
},
12081208
}
12091209
assert.True(t, reflect.DeepEqual(expNumericField, info.Schema.Fields[0]))
@@ -1225,7 +1225,10 @@ func TestClient_InfoFieldsTest(t *testing.T) {
12251225
schema := NewSchema(DefaultOptions).
12261226
AddField(NewTextFieldOptions("text", TextFieldOptions{Sortable: true, PhoneticMatcher: PhoneticDoubleMetaphoneEnglish})).
12271227
AddField(NewGeoField("geo")).
1228-
AddField(NewNumericField("numeric"))
1228+
AddField(NewNumericField("numeric")).
1229+
AddField(NewTextFieldOptions("alias_type", TextFieldOptions{As: "type", Sortable: true, NoIndex: true, NoStem: true})).
1230+
AddField(NewTagFieldOptions("address_city", TagFieldOptions{As: "city"})).
1231+
AddField(NewTagFieldOptions("type", TagFieldOptions{As: "tag", Sortable: true, CaseSensitive: true, NoIndex: true}))
12291232
// In this example we will only index keys started by product:
12301233
indexDefinition := NewIndexDefinition().AddPrefix("ft-info-fields-test:")
12311234
// Add the Index Definition
@@ -1238,8 +1241,12 @@ func TestClient_InfoFieldsTest(t *testing.T) {
12381241
assert.Equal(t,
12391242
[]Field(
12401243
[]Field{
1241-
Field{Name: "text", Type: 0, Sortable: false, Options: TextFieldOptions{Weight: 1, Sortable: true, NoStem: false, NoIndex: false, PhoneticMatcher: "", As: ""}},
1242-
Field{Name: "geo", Type: 2, Sortable: false, Options: interface{}(nil)},
1243-
Field{Name: "numeric", Type: 1, Sortable: false, Options: NumericFieldOptions{Sortable: false, NoIndex: false, As: ""}}}),
1244+
Field{Name: "text", Type: 0, Sortable: true, Options: TextFieldOptions{Weight: 1, Sortable: true, NoStem: false, NoIndex: false, PhoneticMatcher: "", As: "text"}},
1245+
Field{Name: "geo", Type: 2, Sortable: false, Options: GeoFieldOptions{As: "geo", NoIndex: false}},
1246+
Field{Name: "numeric", Type: 1, Sortable: false, Options: NumericFieldOptions{Sortable: false, NoIndex: false, As: "numeric"}},
1247+
Field{Name: "alias_type", Type: 0, Sortable: true, Options: TextFieldOptions{Weight: 1, Sortable: true, NoStem: true, NoIndex: true, PhoneticMatcher: "", As: "type"}},
1248+
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"}},
1250+
}),
12441251
info.Schema.Fields)
12451252
}

redisearch/example_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"os"
1010
"time"
1111

12-
"github.com/RediSearch/redisearch-go/redisearch"
12+
"github.com/RediSearch/redisearch-go/v2/redisearch"
1313
"github.com/gomodule/redigo/redis"
1414
)
1515

redisearch/example_schema_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package redisearch_test
22

33
import (
44
"fmt"
5-
"github.com/gomodule/redigo/redis"
65
"log"
76
"time"
87

9-
"github.com/RediSearch/redisearch-go/redisearch"
8+
"github.com/gomodule/redigo/redis"
9+
10+
"github.com/RediSearch/redisearch-go/v2/redisearch"
1011
)
1112

1213
// exemplifies the CreateIndex function with a temporary index specification

0 commit comments

Comments
 (0)