Diacritic Case-Insensitive search Loopback

前端 未结 1 999
渐次进展
渐次进展 2021-02-14 19:12

Is there any way to query results on Loopback+MongoDB with Diacritic-Case-Insensitive options?

For example, If I want to search for the query olimpic, and t

相关标签:
1条回答
  • 2021-02-14 20:07

    What you want ought to be possible with text indices as of version 3.1.7 of MongoDB. Please see SERVER-19557 for details. Earlier versions can not deal with diacritics.

    Setting up a text index is rather easy: simply create an index on all fields you want to be searched – there can be only one text index per collection:

    db.yourCollection.createIndex(
      {"name.text":"text","foo":"text"},
      {"default_language":"french"}
    )
    

    Now, to search your index, you simply do the following:

    db.yourCollection.find(
      { $text: {$search:"Olimpic"} }
    )
    

    which should give you the expected results.

    hth

    0 讨论(0)
提交回复
热议问题