Do text indexes support partialFilterExpression?

10 views
Skip to first unread message

Cyril Auburtin

unread,
Jan 14, 2017, 3:39:36 PM1/14/17
to mongodb-dev
It's not mentioned in the Docs (for partialFilterExpression or text indexes), but it seems not working with:

> db.txt.find()
> db.txt.createIndex({a:'text'}, {partialFilterExpression: {a: {$type:'array'}}}) // only text index for doc with a as array
{
        "createdCollectionAutomatically" : true,
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "ok" : 1
}
> db.txt.insert({_id:1, b: 'oko'})
WriteResult({ "nInserted" : 1 })
> db.txt.insert({_id:2, a: ['ty', 're']})
WriteResult({ "nInserted" : 1 })
> db.txt.find({$text:{$search:'ty'}})
Error: error: {
        "ok" : 0,
        "errmsg" : "error processing query: ns=test.txtTree: TEXT : query=ty, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL\nSort: {}\nProj: {}\n planner returned error: failed to use text index to satisfy $text query (if text index is compound, are equality predicates given for all prefix fields?)",
        "code" : 2,
        "codeName" : "BadValue"
}
Reply all
Reply to author
Forward
0 new messages