I have a springdata mongodb aggregation where I use
agg = Aggregation.newAggregation(BrkrBean.class, match(criteria),
project("productId, "fullName").and(
StringOperators.valueOf("areas").indexOf(searchString)).as("score"))
This works fine, but how can I do case insensitive search for the searchString. There is no option for indexOf() method.
CodePudding user response:
It is not possible directly. You will have to do some kind of workaround by converting both field value and search string to same case.
StringOperators.valueOf(StringOperators.valueOf("areas").toLower())
.indexOf(StringOperators.valueOf(searchString).toLower())