@Tarun_Gaur I have still not found solution to this, below are the details:-
- MongoDB Version: 4.4.17, Mongo Compass Version: 1.33.1
- Some sample documents:
{
"_id": {
"$oid": "61d6d6a5568e7e17161g3565"
},
"user_details": {
"id": 54,
"name": "A SHIVAKUMAR",
"name_in_lowercase": "a shivakumar",
}
"is_disable": false
"source_with_assessment_id": "course_lesson_95891",
.
.
.
#other fields
}
# basically I want to get results as we do with 'like' query
# so that all the names which has 'shiv' in them apperares in the results eg: shivabc, abcshivdef, abcshiv
Filter - { is_disable: false, source_with_assessment_id: 'course_lesson_95891', "user_details.name_in_lowercase": /shiv/i }
Sort - { "user_details.name_in_lowercase": 1 }
- Please run your query with
execution stats
mode
Here execution time is 6621 ms, but I require results to be in ~100 ms
{
"executionStats": {
"executionSuccess": true,
"nReturned": 26,
"executionTimeMillis": 6621,
"totalKeysExamined": 91735,
"totalDocsExamined": 26,
"executionStages": {
"stage": "FETCH",
"nReturned": 26,
"executionTimeMillisEstimate": 27,
"works": 91736,
"advanced": 26,
"needTime": 91708,
"needYield": 0,
"saveState": 2477,
"restoreState": 2477,
"isEOF": 1,
"docsExamined": 26,
"alreadyHasObj": 0,
"inputStage": {
"stage": "IXSCAN",
"filter": {
"user_details.name_in_lowercase": {
"$regex": "shiv",
"$options": "i"
}
},
"nReturned": 26,
"executionTimeMillisEstimate": 27,
"works": 91735,
"advanced": 26,
"needTime": 91708,
"needYield": 0,
"saveState": 2477,
"restoreState": 2477,
"isEOF": 1,
"keyPattern": {
"is_disable": 1,
"source_with_assessment_id": 1,
"user_details.name_in_lowercase": 1
},
"indexName": "is_disable_1_source_with_assessment_id_1_user_details.name_in_lowercase_1",
"isMultiKey": false,
"multiKeyPaths": {
"is_disable": [],
"source_with_assessment_id": [],
"user_details.name_in_lowercase": []
},
"isUnique": false,
"isSparse": false,
"isPartial": false,
"indexVersion": 2,
"direction": "forward",
"indexBounds": {
"is_disable": [
"[false, false]"
],
"source_with_assessment_id": [
"[\"course_lesson_95891\", \"course_lesson_95891\"]"
],
"user_details.name_in_lowercase": [
"[\"\", {})",
"[/shiv/i, /shiv/i]"
]
},
"keysExamined": 91735,
"seeks": 1,
"dupsTested": 0,
"dupsDropped": 0
}
},
"allPlansExecution":[] # 27 Plans were there
}