-
Notifications
You must be signed in to change notification settings - Fork 69
support for FT.GET, FT.MGET, FT.SUGLEN, FT.SUGDEL, FT.ALIASADD, FT.ALIASUPDATE, FT.ALIASDEL, FT.DICTADD, FT.DICTDEL, FT.DICTDUMP #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b96444b
[add] support for FT.SUGLEN, FT.SUGDEL. Included default options for …
filipecosta90 fcc6707
[merge] merged with master
filipecosta90 db9fc01
[add] improved spellcheck coverage
filipecosta90 6df0c36
[add] no breaking changes on autocompleter
filipecosta90 dc05944
[add] fixed conflicts
filipecosta90 e9ef654
[add] fixed merge conflicts and prunned code
filipecosta90 c07c79e
[add] prunning changes
filipecosta90 f8833ae
[add] prunning changes
filipecosta90 84903f5
[add] Updated Readme with new supported commands
filipecosta90 dc65c2d
[add] support for FT.GET and FT.MGET
filipecosta90 78cab8d
[fix] fixed TestClient_Get
filipecosta90 a198e9c
[add] add support for FT.DICTADD FT.DICTDEL and FT.DICTDUMP
filipecosta90 e97368c
[add] added support for FT.ALIASADD, FT.ALIASUPDATE, FT.ALIASDEL
filipecosta90 31029bc
[add] updated Readme with Alias supported commands
filipecosta90 b7769b1
Merge branch 'master' into ft.sug.refactor
filipecosta90 9e484b4
[add] added missing inline docs
filipecosta90 09c668e
Merge branch 'master' into ft.sug.refactor
filipecosta90 c5e3c09
[fix] fixed conflicts on test files
filipecosta90 f5e7755
[add] added missing inline documents for Single Document Indexing Opt…
filipecosta90 82d2f33
[fix] moved IndexingOptions( represent the options for indexing a sin…
filipecosta90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package redisearch_test | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "github.com/RediSearch/redisearch-go/redisearch" | ||
| "github.com/gomodule/redigo/redis" | ||
| "github.com/stretchr/testify/assert" | ||
| "os" | ||
| "reflect" | ||
| "testing" | ||
| ) | ||
|
|
||
| func createAutocompleter(dictName string) *redisearch.Autocompleter { | ||
| value, exists := os.LookupEnv("REDISEARCH_TEST_HOST") | ||
| host := "localhost:6379" | ||
| if exists && value != "" { | ||
| host = value | ||
| } | ||
| return redisearch.NewAutocompleter(host, dictName) | ||
| } | ||
|
|
||
| func TestAutocompleter_Serialize(t *testing.T) { | ||
| fuzzy := redisearch.DefaultSuggestOptions | ||
| fuzzy.Fuzzy = true | ||
| withscores := redisearch.DefaultSuggestOptions | ||
| withscores.WithScores = true | ||
| withpayloads := redisearch.DefaultSuggestOptions | ||
| withpayloads.WithPayloads = true | ||
| all := redisearch.DefaultSuggestOptions | ||
| all.Fuzzy = true | ||
| all.WithScores = true | ||
| all.WithPayloads = true | ||
|
|
||
| type fields struct { | ||
| name string | ||
| } | ||
| type args struct { | ||
| prefix string | ||
| opts redisearch.SuggestOptions | ||
| } | ||
| tests := []struct { | ||
| name string | ||
| fields fields | ||
| args args | ||
| want redis.Args | ||
| want1 int | ||
| }{ | ||
| {"default options", fields{"key1"}, args{"ab", redisearch.DefaultSuggestOptions,}, redis.Args{"key1", "ab", "MAX", 5}, 1}, | ||
| {"FUZZY", fields{"key1"}, args{"ab", fuzzy,}, redis.Args{"key1", "ab", "MAX", 5, "FUZZY"}, 1}, | ||
| {"WITHSCORES", fields{"key1"}, args{"ab", withscores,}, redis.Args{"key1", "ab", "MAX", 5, "WITHSCORES"}, 2}, | ||
| {"WITHPAYLOADS", fields{"key1"}, args{"ab", withpayloads,}, redis.Args{"key1", "ab", "MAX", 5, "WITHPAYLOADS"}, 2}, | ||
| {"all", fields{"key1"}, args{"ab", all,}, redis.Args{"key1", "ab", "MAX", 5, "FUZZY", "WITHSCORES", "WITHPAYLOADS"}, 3}, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| a := redisearch.NewAutocompleterFromPool(nil, tt.fields.name) | ||
| got, got1 := a.Serialize(tt.args.prefix, tt.args.opts) | ||
| if !reflect.DeepEqual(got, tt.want) { | ||
| t.Errorf("serialize() got = %v, want %v", got, tt.want) | ||
| } | ||
| if got1 != tt.want1 { | ||
| t.Errorf("serialize() got1 = %v, want %v", got1, tt.want1) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSuggest(t *testing.T) { | ||
| a := createAutocompleter("testing") | ||
|
|
||
| // Add Terms to the Autocompleter | ||
| terms := make([]redisearch.Suggestion, 10) | ||
| for i := 0; i < 10; i++ { | ||
| terms[i] = redisearch.Suggestion{Term: fmt.Sprintf("foo %d", i), | ||
| Score: 1.0, Payload: fmt.Sprintf("bar %d", i)} | ||
| } | ||
| err := a.AddTerms(terms...) | ||
| assert.Nil(t, err) | ||
| suglen, err := a.Length() | ||
| assert.Nil(t, err) | ||
| assert.Equal(t, int64(10), suglen) | ||
| // Retrieve Terms From Autocompleter - Without Payloads / Scores | ||
| suggestions, err := a.SuggestOpts("f", redisearch.SuggestOptions{Num: 10}) | ||
| assert.Nil(t, err) | ||
| assert.Equal(t, 10, len(suggestions)) | ||
| for _, suggestion := range suggestions { | ||
| assert.Contains(t, suggestion.Term, "foo") | ||
| assert.Equal(t, suggestion.Payload, "") | ||
| assert.Zero(t, suggestion.Score) | ||
| } | ||
|
|
||
| // Retrieve Terms From Autocompleter - With Payloads & Scores | ||
| suggestions, err = a.SuggestOpts("f", redisearch.SuggestOptions{Num: 10, WithScores: true, WithPayloads: true}) | ||
| assert.Nil(t, err) | ||
| assert.Equal(t, 10, len(suggestions)) | ||
| for _, suggestion := range suggestions { | ||
| assert.Contains(t, suggestion.Term, "foo") | ||
| assert.Contains(t, suggestion.Payload, "bar") | ||
| assert.NotZero(t, suggestion.Score) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.