4

We are developing an Application on Spring 5 Reactive Stack. For persistance we use MongoDb with ReactiveMongoRepository (ReactiveCrudRepository) from Spring Data.

Currently for fetching data we are using a Query like

@Query("{ 'ownerId': ?0, filePath: {$regex: ?1}, tags: { $all : ?2}}")
Flux<Media> findAllByOwnerIdAndFilePathRegexAndTagsContainingAll(String ownerId, String pathRegex, List<Tag> tags);

Now we want to get the data by incasesensitive tags. For this I've created a index in the db with a collation like { locale: 'en', strength: 2 } as described here.

Now i want to get my data from db with using the index. The MonogoDB way would be db.media.find( { filePath: "/example/" } ).collation( { locale: 'en', strength: 2 } ).

Does someone know a smart way to use Collations from ReactiveMongoRepository?

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
JohnnyJ
  • 43
  • 1
  • 4

1 Answers1

1

With the current versions of Spring Data you need to use MongoOperations providing a Query that defines the Collation.
Please refer to the Reference Documentation for details on that.

Please make sure to also check out/comment on DATAMONGO-1854 which proposes adding collation to @Query.

Christoph Strobl
  • 6,491
  • 25
  • 33