Open
Description
Bug description
When using the FilterExpressionBuilder with PgVectorStore, for example:
FilterExpressionBuilder b = new FilterExpressionBuilder();
b.and(
b.or(
b.eq( "tenantId", context.getTenantId() ),
b.eq( "tenantId", this.globalTenantId )
),
b.ne( "docId", userJobDescriptionDocId )
).build()
and sending that to the SearchRequest.builder, it doesn't work properly because the final expression that is generated does not use parentheses, and so the expression is broken. you end up with: x || y && z
Environment
any
Steps to reproduce
see description
Expected behavior
The expressions, ANDs and ORs should contain parentheses.
Minimal Complete Reproducible example
FilterExpressionBuilder b = new FilterExpressionBuilder();
chatClientRequestSpec.advisors(
QuestionAnswerAdvisor.builder( vectorStore ).searchRequest(
SearchRequest.builder().query( chatRequest.getPrompt() ).similarityThreshold( .70 ).topK( 5 ).filterExpression(
b.and(
b.or(
b.eq( "tenantId", tenantId1 ),
b.eq( "tenantId", tenantId2 )
),
b.ne( "docId", docId )
).build()
).build()
).build()
).stream().chatResponse()