[SERVER-13018] $text queries can't be covered on text index prefix fields Created: 03/Mar/14  Updated: 28/Dec/23

Status: Backlog
Project: Core Server
Component/s: Text Search
Affects Version/s: 2.6.0-rc0
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 3
Labels: 26qa, qi-text-search, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Integration
Participants:

 Description   

> db.foo.insert({a:1,b:"hello"})
WriteResult({ "nInserted" : 1 })
> db.foo.ensureIndex({b:"text",a:1})
WriteResult({ "nInserted" : 1 })
> db.foo.find({a:1,$text:{$search:"hello"}},{_id:0,a:1}).explain()
{
	"cursor" : "TextCursor",
	"n" : 1,
	"nscannedObjects" : 0, // Good: text index correctly covers this query
	"nscanned" : 1,
	"nscannedObjectsAllPlans" : 0,
	"nscannedAllPlans" : 1,
	"scanAndOrder" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"server" : "Rassi-MacBook-Pro.local:27017",
	"filterSet" : false
}
> db.foo.dropIndexes()
{
	"nIndexesWas" : 2,
	"msg" : "non-_id indexes dropped for collection",
	"ok" : 1
}
> db.foo.ensureIndex({a:1,b:"text"})
WriteResult({ "nInserted" : 1 })
> db.foo.find({a:1,$text:{$search:"hello"}},{_id:0,a:1}).explain()
{
	"cursor" : "TextCursor",
	"n" : 1,
	"nscannedObjects" : 1, // Bad: text index should be able to cover this query
	"nscanned" : 1,
	"nscannedObjectsAllPlans" : 1,
	"nscannedAllPlans" : 1,
	"scanAndOrder" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"server" : "Rassi-MacBook-Pro.local:27017",
	"filterSet" : false
}
>

This type of query is "coverable" (nscannedObjects=0) with the text command in version 2.4.


Generated at Thu Feb 08 03:30:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.