Case Insensitive search with $in

case-insensitive search in sql
oracle sql ignore case
sql case-insensitive like
sqlserver case insensitive like
mysql case-insensitive
how to check uppercase and lowercase in sql
sql like case-insensitive postgres
sql case sensitive or not

How to search a column in a collection in mongodb with $in which includes an array of elements for search and also caseInsensitive matching of those elements in the column ?

You can use $elemMatch with regular expressions search, e.g. let's search for "blue" color in the following collection:

db.items.save({ 
  name : 'a toy', 
  colors : ['red', 'BLUE'] 
})
> ok
db.items.find({
  'colors': {
    $elemMatch: { 
      $regex: 'blue', 
      $options: 'i' 
    }
  }
})
>[ 
  {   
    "name": "someitem",
    "_id": { "$oid": "4fbb7809cc93742e0d073aef"},   
    "colors": ["red", "BLUE"]
   }
]

Case insensitive SQL SELECT query examples, Case insensitive SQL SELECT query FAQ: How do I issue SQL SELECT queries while ignoring case (ignoring whether a string is uppercase or  The mispelling “wiwek” is the search pattern and the “vivek” is the replacement string. By default, sed is case-sensitive. You can add an “i” OR “I” flag at the end of the substitution to change this. To perform a case-insensitive search, enter:

Use $in with the match being case insensitive:

Data example:

{ 
    name : "...Event A",
    fieldX : "aAa" 
},
{ 
  name : "...Event B",
  fieldX : "Bab" 
},
{ 
  name : "...Event C",
  fieldX : "ccC" 
},
{ 
  name : "...Event D",
  fieldX : "dDd" 
}

And we want documents were "fieldX" is contained in any value of the array (optValues):

var optValues = ['aaa', 'bbb', 'ccc', 'ddd'];

var optRegexp = [];
optValues.forEach(function(opt){
        optRegexp.push(  new RegExp(opt, "i") );
});

db.collection.find( { fieldX: { $in: optRegexp } } );

This works for $all either.

I hope this helps!

p.s.: This was my solution to search by tags in a web application.

Linux: Case-insensitive file searching with locate and find , I was happy to learn that both of my favorite Unix and Linux file-finding utilities support case-insensitive file searching. Both the find command  Finding A Case Insensitive Sub String using Boost::icontains. With boost::icontains we can check if a sub string exists in a given string i.e. std::string data = "Hi this is a sample string"; // Case Insensitive Sub String Search bool result = boost::icontains(data, "SAMPLE"); But we can not find out the position of substring with it 🙁

This works for me perfectly.

From code we can create custom query like this:

{
  "first_name":{
    "$in":[
      {"$regex":"^serina$","$options":"i"}, 
      {"$regex":"^andreW$","$options":"i"}
    ]
  }
}

This will transform to following in mongo after query:

db.mycollection.find({"first_name":{"$in":[/^serina$/i, /^andreW$/i]}})

Same for "$nin".

Case Insensitive search with $in, You can use $elemMatch with regular expressions search, e.g. let's search for "​blue" color in the following collection: db.items.save({ name : 'a  Ignore case : Check if a String contains another string in case-insensitive manner To check if a given string or a character exists in an another string or not in case insensitive manner i.e. by ignoring case, we need to first convert both the strings to lower case then use “ïn” or “ not ïn ” operator to check the membership of sub

This is pretty simple

const sampleData = [
  RegExp("^" + 'girl' + "$", 'i'),
  RegExp("^" + 'boy' + "$", 'i')
];
const filerObj = { gender : {$in : sampleData}};

Case insensitive search in man pages, When no other pager is specified, man uses less to display man pages. The other answers that involve changing the pager command line are correct, but you  Case-Insensitive INSTR Test. By default, VBA treats “L” different from “l”. In other words, VBA is case-sensitive. This is true of all text functions. To make VBA case-insensitive, set the [compare] argument to 1 or vbTextCompare.

Here is my case insensitive search (query) with multiple condition (regex) from data of array, I've used $in but it doesn't support case insensitive search.

Example Data

{ 
  name : "...Event A",
  tags : ["tag1", "tag2", "tag3", "tag4] 
},
{ 
  name : "...Event B",
  tags : ["tag3", "tag2"]
},
{ 
  name : "...Event C",
  tags : ["tag1", "tag4"]
},
{ 
  name : "...Event D",
  tags : ["tag2", "tag4"]
}

My query

db.event.find(
  { $or: //use $and or $or depends on your needs
    [ 
      { tags : { 
         $elemMatch : { $regex : '^tag1$', $options : 'i' }
        } 
      },
      { tags : { 
         $elemMatch : { $regex : '^tag3$', $options : 'i' }
        } 
      }
    ]
})

Case insensitive search in JavaScript, Case insensitive search in JavaScript. Case-insensitive: It means the text or typed input that is not sensitive to capitalization of letters, like “Geeks” and “​GEEKS”  Case-Insensitive Search Using UPPER or LOWER Ignoring the case in a where clause is very simple. You can, for example, convert both sides of the comparison to all caps notation:

Case Insensitive search from find command?, By default, search in IDOL Content is not case sensitive. This means that a search for a term matches other occurrences of that term, regardless of their case in  Case-insensitive file searching with the locate command. It's easy to perform a case-insensitive file search with the Linux locate command: just add the -i flag. To search my entire filesystem for files and directories that contain the string typeahead, just use this command: locate -i typeahead Case-insensitive file searching with the find command

Case-Sensitive Search, Cloudant Blog: Making Cloudant query, search and MapReduce case sensitive or case-insensitive. I hope these case insensitive SQL SELECT query examples are helpful. Again, the trick is to convert whatever you’re searching for to uppercase or lowercase using the SQL upper and lower functions, and then make your search string match that case.

Case-sensitivity in queries, How to run a case-insensitive search for one string inside another. Swift version: 5.2. Paul Hudson @twostraws May 28th 2019. You can search for one string  A case-insensitive search is more comprehensive, finding "Language" (at the beginning of a sentence), "language", and "LANGUAGE" (in a title in capitals); a case-sensitive search will find the computer language "BASIC" but exclude most of the many unwanted instances of the word.

Comments
  • Apart from the $in operator, this is a duplicate of stackoverflow.com/questions/1863399/…
  • Ya right. my question was basically related to caseinsensitive match with $in operator.
  • You can use $caseSensitive: false. Refer here : docs.mongodb.com/manual/reference/operator/query/text/…
  • One note: this regex will not use index. So, such solution does not fit for 'big data'. Another solution is to support same lowercased array.
  • Indeed. Thank you for mentioning that.
  • this is not useful when the we need to check over a array of value
  • worked for Ruby needs as well thanks.. just used Regexp.new(opt, Regexp::IGNORECASE) in place of new RegExp(tag, "i")
  • What will be the java code to run this Example in Java or Spring mongodbTemplete.
  • Can be simplified to var optRegexp = optValues.map(value => new RegExp("^" + value + "$", "i"); to use with { $in: optRegexp }