StackExchange / NRediSearch

Other
31 stars 9 forks source link

NRedisearch issue with the search for "bond" #3

Open elan-echambon opened 3 years ago

elan-echambon commented 3 years ago

Hi,

I see a very weird behaviour with the C# client when creating a suggestion and then looking for it. Here is the code :

// Creating the client var client = new NRediSearch.Client("redisearch:error", / IDatabase /);

// Adding the suggestion var nameBuilder = new Suggestion.SuggestionBuilder(); nameBuilder.String("bond"); nameBuilder.Score(0.5); nameBuilder.Payload("test"); client.AddSuggestion(nameBuilder.Build());

// Querying it var optionsBuilder = new SuggestionOptions.SuggestionOptionsBuilder(); optionsBuilder.With(SuggestionOptions.WithOptions.PayloadsAndScores); optionsBuilder.Max(10); optionsBuilder.Fuzzy(); var suggestionsOptions = optionsBuilder.Build(); var res = client.GetSuggestions("bond", suggestionsOptions);

Am i missing something obvious or is it a bug ? Also if you replace "bond" by something else, it does work sometimes and sometimes doesn't.

Thanks

StackTrace: StackExchange.Redis.RedisCommandException: Missing required fields: score not within range: 2147483648 at NRediSearch.Suggestion.SuggestionBuilder.Build() in //src/NRediSearch/Suggestion.cs:line 102 at NRediSearch.Client.GetSuggestionsWithPayloadAndScores(RedisResult[] results) in //src/NRediSearch/Client.cs:line 1271 at NRediSearch.Client.GetSuggestions(String prefix, SuggestionOptions options) in /_/src/NRediSearch/Client.cs:line 813 at Cobra.Timeseries.TestClient.RedisSearchError.Run() in C:\repositories\cobra\Cobra\Cobra.Timeseries.TestClient\RedisSearchError.cs:line 30

mgravell commented 3 years ago

I observed something similar when testing the RediSearch 2 changes (are you using RediSearch 2 by any chance?) - see this fix here. I had been hoping for some feedback from @gkorland on some questions including this topic, but I may have to just give up on that and review for final merge

elan-echambon commented 3 years ago

Hi Marc,

Thanks a lot for your quick answer. I'm using RediSearch version 2.0.1 (running on Redis 6.0.9) on the server and the C# client is version 2.1.30 (latest available). Looking at the fix, it does look like it would fix the issue - I'm happy to test this usecase once merged and released.

Thanks

elan-echambon commented 3 years ago

Hi @mgravell @gkorland , did you have the time to look into this? Would be good to merge if everyone is happy