Env:
- MongoDB (3.2.0) with Mongoose
Collection:
- users
Text Index creation:
  BasicDBObject keys = new BasicDBObject();
  keys.put("name","text");
  BasicDBObject options = new BasicDBObject();
  options.put("name", "userTextSearch");
  options.put("unique", Boolean.FALSE);
  options.put("background", Boolean.TRUE);
  
  userCollection.createIndex(keys, options); // using MongoTemplate
Document:
- {"name":"LEONEL"}
Queries:
- db.users.find( { "$text" : { "$search" : "LEONEL" } } )=> FOUND
- db.users.find( { "$text" : { "$search" : "leonel" } } )=> FOUND (search caseSensitive is false)
- db.users.find( { "$text" : { "$search" : "LEONÉL" } } )=> FOUND (search with diacriticSensitive is false)
- db.users.find( { "$text" : { "$search" : "LEONE" } } )=> FOUND (Partial search)
- db.users.find( { "$text" : { "$search" : "LEO" } } )=> NOT FOUND (Partial search)
- db.users.find( { "$text" : { "$search" : "L" } } )=> NOT FOUND (Partial search)
Any idea why I get 0 results using as query "LEO" or "L"?
Regex with Text Index Search is not allowed.
db.getCollection('users')
     .find( { "$text" : { "$search" : "/LEO/i", 
                          "$caseSensitive": false, 
                          "$diacriticSensitive": false }} )
     .count() // 0 results
db.getCollection('users')
     .find( { "$text" : { "$search" : "LEO", 
                          "$caseSensitive": false, 
                          "$diacriticSensitive": false }} )
.count() // 0 results
MongoDB Documentation:
 
     
     
     
     
     
     
     
     
     
     
     
    