MomgoTemplate alike function not working as expected

29 views Asked by At

I am using MongoTemplate in SpringBoot application to access the data. I have to query to DB and I am using "Criteria" object to create a query.

I want to write a query which search data using "alike" funciton.

Query query = new Query();        
List<Criteria> criterias = new ArrayList<>();
criterias.add(Criteria.where(DATA).alike(Example.of(text)));
criterias.add(Criteria.where(POST).alike(Example.of(text)));
query.addCriteria(new Criteria().orOperator(criterias));

When the code runs it fails and showing the error like: enter image description here

Dont know what the issue is.

Any idea?

Thanks,

Atul

1

There are 1 answers

0
Atul On BEST ANSWER

The workaround I used is replace "alike" function with "regex" and make necessary changes to run the code.

There is bug in the "alike" function. (I debug the code)

Atul