How to do a Case Insensitive search on Azure DocumentDb?

前端 未结 3 877
盖世英雄少女心
盖世英雄少女心 2020-12-10 11:15

is it possible to perform a case insensitive search on DocumnetDb?

Let\'s say I have a record with \'name\' key and value as \"Timbaktu\"

This will work:

3条回答
  •  伪装坚强ぢ
    2020-12-10 11:31

    There are two ways to do this. 1. use the built-in LOWER/UPPER function, for example,

    select * from json j where LOWER(j.name) = 'timbaktu'
    

    This will require a scan though. Another more efficient way is to store a "canonicalized" form e.g. lowercase and use that for querying. For example, the JSON would be

    { name: "Timbaktu", nameLowerCase: "timbaktu" }
    

    Then use it for querying like:

    select * from json j WHERE j.nameLowerCase = "timbaktu"
    

    Hope this helps.

提交回复
热议问题