I'm trying to write a "startsWith" query in Spring Data, using MongoDB. If I write this in Mongo shell, it works, lists every e-mail address starting with letter x or X (case insensitive): db.user.find({email:/^x/i})
However, this doesn't:
@Query(value = "{'$or':[{'name':?0},{'email':?0}]}")
List<User> findAllByFreeTextSearch(String keyword);
I tried to add the /^.../i to the keyword itself, and in a dozen combinations to the @Query but without luck. What is the correct syntax?