I have some cloud code that is trying to do a case insensitive find and it’s not working. I’m not sure where to start digging in so any pointers would be appreciated. Here are the details:
// cloud code
const query = new Parse.Query('Artist');
query.equalTo('ens','RAc.eth');
// also tried hinting to use index but still no results
// query.hint('ens_unique1');
query.explain();
const result = await query.find({caseInsensitive:true});
// above returns no results
// mongosh query works: db.Artist.find({ens:'RAc.eth'}).collation( { locale: 'en', strength: 2 } );
The class Artist has an index on the property ‘ens’ that specifies collation:
{
v: 2,
key: { ens: 1 },
name: 'ens_unique1',
unique: true,
partialFilterExpression: { ens: { '$exists': true } },
collation: {
locale: 'en_US',
caseLevel: false,
caseFirst: 'off',
strength: 2,
numericOrdering: false,
alternate: 'non-ignorable',
maxVariable: 'punct',
normalization: false,
backwards: false,
version: '57.1'
}
Here’s the output of explain:
verbose: RESPONSE from [GET] /parse/classes/Artist: {
"response": {
"results": {
"explainVersion": "1",
"queryPlanner": {
"namespace": "crush.Artist",
"indexFilterSet": false,
"parsedQuery": {
"$and": [
{
"ens": {
"$eq": "RAc.eth"
}
},
{
"_rperm": {
"$in": [
null,
"*"
]
}
}
]
},
"queryHash": "240CEE43",
"planCacheKey": "2E6DB2D8",
"maxIndexedOrSolutionsReached": false,
"maxIndexedAndSolutionsReached": false,
"maxScansToExplodeReached": false,
"winningPlan": {
"stage": "LIMIT",
"limitAmount": 100,
"inputStage": {
"stage": "COLLSCAN",
"filter": {
"$and": [
{
"ens": {
"$eq": "RAc.eth"
}
},
{
"_rperm": {
"$in": [
null,
"*"
]
}
}
]
},
"direction": "forward"
}
},
"rejectedPlans": []
},
"executionStats": {
"executionSuccess": true,
"nReturned": 0,
"executionTimeMillis": 27,
"totalKeysExamined": 0,
"totalDocsExamined": 34472,
"executionStages": {
"stage": "LIMIT",
"nReturned": 0,
"executionTimeMillisEstimate": 2,
"works": 34474,
"advanced": 0,
"needTime": 34473,
"needYield": 0,
"saveState": 34,
"restoreState": 34,
"isEOF": 1,
"limitAmount": 100,
"inputStage": {
"stage": "COLLSCAN",
"filter": {
"$and": [
{
"ens": {
"$eq": "RAc.eth"
}
},
{
"_rperm": {
"$in": [
null,
"*"
]
}
}
]
},
"nReturned": 0,
"executionTimeMillisEstimate": 2,
"works": 34474,
"advanced": 0,
"needTime": 34473,
"needYield": 0,
"saveState": 34,
"restoreState": 34,
"isEOF": 1,
"direction": "forward",
"docsExamined": 34472
}
},
"allPlansExecution": []
},
"command": {
"find": "Artist",
"filter": {
"ens": "RAc.eth",
"_rperm": {
"$in": [
null,
"*",
"*"
]
}
},
"projection": {},
"limit": 100,
"$db": "crush"
},
"serverInfo": {
"host": "clt-mbp.local",
"port": 27017,
"version": "6.0.1",
"gitVersion": "32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b"
},
"serverParameters": {
"internalQueryFacetBufferSizeBytes": 104857600,
"internalQueryFacetMaxOutputDocSizeBytes": 104857600,
"internalLookupStageIntermediateDocumentMaxSizeBytes": 104857600,
"internalDocumentSourceGroupMaxMemoryBytes": 104857600,
"internalQueryMaxBlockingSortMemoryUsageBytes": 104857600,
"internalQueryProhibitBlockingMergeOnMongoS": 0,
"internalQueryMaxAddToSetBytes": 104857600,
"internalDocumentSourceSetWindowFieldsMaxMemoryBytes": 104857600
},
"ok": 1
}