Skip to content

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

@ankurgar

Description

@ankurgar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions