-
Notifications
You must be signed in to change notification settings - Fork 79
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
False positive when using Any on nested array #461
Comments
Hi @SapiensAnatis - yeah this is frustratingly both:
RediSearch allows you to index any field that is either:
Which of course you are taking advantage of here. The filters however only tell you whether a given record matches the filter. So in your case here, both of those records match the filter. in case one there IS an ID in
that's what you are going to be matching against, it's not running a full filter to ensure there's an individual player that matches all the criteria, just that there is a player that matches each of the criteria. |
Thanks for the explanation @slorello89 - based on the research I had done into RediSearch I had a feeling it wasn’t quite possible to translate that expression, but I didn’t want to say so for sure. Would it be an idea for the library to throw an exception stating it can’t translate the expression in this case? This is something that Entity Framework Core does quite often when it encounters an expression tree construct that can’t be converted into SQL. It would have definitely saved me some debugging, as the expression did appear to be working correctly when initially I only had one player in the list. |
Hmm, I'd be hesitant to do that, this behavior has been in Redis OM .NET and RediSearch for some time now, so while it's a little quirky, my guess is that the quirk is load-bearing somewhere. A better route is probably to just add to the FAQ/README. |
Yeah, I can understand your reluctance to change this behaviour if it’s already shipped. Documentation would be good. I wonder if it’s possible to make an analyzer that could warn about queries that are likely to exhibit this behaviour? |
added some commentary to the readme in #467 to address this, so I'm going to go ahead and close this issue. |
Version: 0.7.3
Hey, thank you for your work on this library. It's really simplified an app I'm making to store active co-op games.
I hit a little bit of a snag trying to index a sub-array of my object. It seems like my query is returning
true
when I don't want it to. I put together this minimal example:What I want to do with the
AnyAsync
is test if a particular ID is hosting a game - that is, that there exists a game with a player whose ID is 1 AND whose actor number is 1. But when I run that program I get:I would expect:
The queries that redis-om is running (according to
monitor
) areMy knowledge of RediSearch is quite lacking, but I believe that is searching for any game that has a player with an actor number of 1, and that has a player with an actor number of 2. These could be two different players, so I don't think it really satisfies the LINQ expression I wrote. Unfortunately I'm not good enough with RediSearch to know what the correct query is here.
I have been able to work around this issue by loading all games onto the client and doing my filtering in .NET, which is fine for my use case as it is not a huge amount of data. But I thought it would be best to raise this as it seems like a probable bug.
The text was updated successfully, but these errors were encountered: