[SERVER-58799] Query Planner splits search string in terms even if it's between quotes Created: 23/Jul/21 Updated: 27/Oct/23 Resolved: 26/Jul/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.2.15 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | rayden hayden | Assignee: | Edwin Zhou |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
I am using $text $search between double quotes to search Star System names in my database(~4.5milion records). The problem is that the query planner splits my search string into two terms (TRAPPIST and 1) and performs a full scan of the collection (which has a lot of names with xxx-xxx-1 in it) and the query goes over the 20 second timeout set for the web service accessing the database. It should be an instant find of 1 document, but the query planner goes through all those "1" documents for nothing. "$text" : { "$search" : "\"TRAPPIST-1\"" } Check my attached query planner, it has two IXSCANs and the terms are split into ["1","TRAPPIST"]. For a scan of the text TRAPPIST (no "-1") there is only one term and one IXSCAN and the query finishes in ~200ms.
|
| Comments |
| Comment by Edwin Zhou [ 26/Jul/21 ] |
|
Thanks for your report. The hyphen-minus character is reserved for text negation when performing a text search. When this character is used to describe a hyphenated word, it is treated as a delimiter, which explains why your query looks for two terms, "TRAPPIST" and "1", and searches for the phrase "TRAPPIST-1". Please note that the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket appears to describe intended behavior, I will now close it as works as designed. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the MongoDB Developer Community Forums. If your discussion on our community forums leads you to believe that this may be a bug, or a feature can benefit from an improvement, please let us know and we will be happy to reopen this ticket and continue our investigation! Best, |