Skip to content
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

QueryFlags - An item with the same key has already been added #310

Open
mitjaahlin opened this issue Feb 20, 2023 · 1 comment
Open

QueryFlags - An item with the same key has already been added #310

mitjaahlin opened this issue Feb 20, 2023 · 1 comment

Comments

@mitjaahlin
Copy link

Hi,
while testing Redis.OM library we bumped into the problem with internal logic of SearchResponse.

Adding WithScores query flag to SearchAsync causes internal dictionary to try break if two documents have the same score.
var query = new RedisQuery("companies");
query.QueryText = ($"(@LastName:%{lastName}%)|(@FirstName:%{firstName}%)|(@Aliases:%{aliases}%)");
query.Flags = (long)QueryFlags.WithScores;
var companies = await _client.Connection.SearchAsync<Company>(query);

An item with the same key has already been added. Key: 38
System.ArgumentException: An item with the same key has already been added. Key: 38
at System.Collections.Generic.Dictionary.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary.Add(TKey key, TValue value)
at Redis.OM.Searching.SearchResponse..ctor(RedisReply val)
at Redis.OM.RediSearchCommands.SearchAsync[T](IRedisConnection connection, RedisQuery query)

@slorello89
Copy link
Member

Hmm interesting, yeah this is using the raw Search API(which admittedly isn't fully tested outside what we do with LINQ expressions), I suspect there's something a bit different about the way the result is formatted coming back from RediSearch that's causing this to break like this - will have to dig into it. Thanks for bringing this to my attention @mitjaahlin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants