添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
含蓄的山楂  ·  Help with php artisan ...·  3 月前    · 
大气的稀饭  ·  Csharp类型转换汇总·  4 月前    · 
爱玩的小笼包  ·  Uncaught (in promise) ...·  5 月前    · 
不拘小节的羽毛球  ·  android ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
org.springframework.data.mongodb.UncategorizedMongoDbException: 
Can't canonicalize query: BadValue unknown top level operator: $in; 
nested exception is com.mongodb.MongoException: Can't canonicalize query: BadValue unknown top level operator: $in

So after many trial and errors, turns out it's simpler (although a little counter-intuitive in my opinion) than it thought:

Criteria.where("field").regex(searchText);
                this is not working for me. I have List<String> tags and want to search with searchStr                       I have code like this      String regex = ".*" + searchText + ".*";  Criteria.where("tags").regex(regex). But this is not giving results.
– user3863488
                Aug 23, 2020 at 16:05

This is working

List<Pattern> regs = new ArrayList<Pattern>()
regs.add(Pattern.compile(regex, Pattern.CASE_INSENSITIVE))
Criteria.where("tags").regex(regs)
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.