Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
I am using Kotlin / Spring Data and I have a problem querying with regex using MongoTemplate.aggregate()
Creating the Criteria:
override fun createFilterCriteria(value: String): Criteria = Criteria.where(AEHProduct::searchText.name).regex(value)
After passing everything to MongoTemplate.aggregate() (The criteria is added to the MatchOperation), and I can see in the server logs that it is parsed as well:
I am using Kotlin / Spring Data and I have a problem querying with regex using MongoTemplate.aggregate()
Creating the Criteria:
override fun createFilterCriteria(value: String): Criteria = Criteria.where(AEHProduct::searchText.name).regex(value)
After passing everything to MongoTemplate.aggregate() (The criteria is added to the MatchOperation), and I can see in the server logs that it is parsed as well:
Executing aggregation: ... { "searchText" : { "$regularExpression" : { "pattern" : "hh4mvorvlhz", "options" : ""}}} ...
When I catch the query on the database side, it is empty, resulting in 0 results:
... { "searchText": {} } ...
Other filters (in, nin, eq, etc..) and sorting/skipping/grouping are working fine.
org.mongodb:bson version: 4.11.1 spring-boot-starter-data-mongodb version: from spring-boot-starter-parent 3.2.4