Skip to content

OR Conjunction Condition is not wrapping self and chained condition within parenthesis #66

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

Open
ankurgar opened this issue Apr 3, 2025 · 4 comments

Comments

@ankurgar
Copy link

ankurgar commented Apr 3, 2025

Sample condition

import com.redis.lettucemod.search.SearchOptions;
import com.redis.lettucemod.search.SearchResults;
import com.redis.lettucemod.search.Limit;
import com.redis.lettucemod.search.Document;
import com.redis.query.Query;
import com.redis.search.query.filter.Condition;
...

      Condition statusOrOnHandCases = Query.tag("status").in("A")
              .or(Query.numeric("onHandCases").ge(0));

      System.out.println("statusOrOnHandCases = "+  statusOrOnHandCases.getQuery());
....

Generated Query String

statusOrOnHandCases = @status:{A}|@onHandCases:[0 inf]

Failure stacktrace

io.lettuce.core.RedisCommandExecutionException: Syntax error at offset 15 near onHandCases
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:147)
	at io.lettuce.core.internal.Exceptions.bubble(Exceptions.java:72)
	at io.lettuce.core.internal.Futures.awaitOrCancel(Futures.java:250)
	at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:75)
	at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
	at jdk.proxy2/jdk.proxy2.$Proxy2.ftSearch(Unknown Source)
	at com.my-app.RedisQueryPoc.main(RedisQueryPoc.java:86)
Caused by: io.lettuce.core.RedisCommandExecutionException: Syntax error at offset 158 near onHandCases
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:147)
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:116)
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
	at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
	at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:745)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:680)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:597)

Expected Query String

  1. ((@status:{A}) | (@onHandCases:[0 +inf])) --- with wrapping parenthesis at inner and outer
    OR
  2. (@status:{A}) | (@onHandCases:[0 +inf]) --- with wrapping parenthesis at inner condition

SQL : WHERE x='foo' OR y='bar'
REDIS : (@x:foo)\|(@y:bar)

Self Assessments and Validation

Request / Ask

  1. Let me know if I am not using the write constructs to chain or conditions.
  2. If the construct seems appropriate, then it looks like a potential bug in the OR condition implementation, kindly address and fix. Also this seems like a pretty basic implementation expectation for or condition not sure why this is missed.

Version Details

lettucemod version : 4.2.1
lettucemod-query version : 4.2.1

@ankurgar
Copy link
Author

ankurgar commented Apr 3, 2025

@ankurgar
Copy link
Author

ankurgar commented Apr 7, 2025

@banker / @sundb / @yossigo / @jruaux - gentle reminder to checkout this issue, and please let me know whether it's genuine issue or am I missing something in the implementation ?

@ankurgar
Copy link
Author

https://github.com/redis/lettucemod/pull/67/files fixes this issue.

@kicktocode
Copy link
Contributor

#72

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