2011-02-12 12 views

Respuesta

28

Intente utilizar los objetos regex de python en su lugar. Pymongo los serializará correctamente:

import re 
config.gThingCollection.find({"name": re.compile(regex, re.IGNORECASE)}) 
17

Puede usar las opciones de expresiones regulares de MongoDB en su consulta.

config.gThingCollection.find({"name":{"$regex":regex, "$options": "-i"}}) 
1
res = posts.find({"geography": {"$regex": 'europe', "$options": 'i'}}) 

# if you need use $not 
import re 
res = posts.find(
    {"geography": {"$not": re.compile('europe'), "$options": 'i'}}) 
Cuestiones relacionadas