We are trying to implement searchRequest and set filter expression by using SearchRequest.withFilterExpression(String textExpression). However, the metadata field name we used has "_"(underscore) and it results in the error like this: Spring-ai SearchRequest.withFilterExpression(String textExpression) errors when metadata field name has Error example is: searchRequest.withFilterExpression("country_code == 'UK'");

We tried to use Filter.Expression expression instead of plain string and it does work. Example is: searchRequest.withFilterExpression(new FilterExpressionBuilder().eq("country_code", "UK").build()); However, we need to build a more complex query that can't be implemented with the current collection of ExpressionType(Filter expression operations).

Comment From: markpollack

Can you add single quotes around country_code, eg. searchRequest.withFilterExpression(" 'country_code' == 'UK'");

Comment From: xiaonan2323

Adding single quotes around field name fixed it, thank you.