[SERVER-61259] $or queries with text indexes fail on clustered collections Created: 04/Nov/21  Updated: 29/Oct/23  Resolved: 16/Jun/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Louis Williams Assignee: Gil Alon
Resolution: Fixed Votes: 0
Labels: query-director-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-77280 $or queries only produce collscan for... Closed
depends on SERVER-77854 Avoid re-parsing query in CanonicalQu... Closed
depends on SERVER-13803 Query planner should be able to plan ... Backlog
Related
related to SERVER-78045 Nested $or queries with $text nodes s... Backlog
related to SERVER-78044 Cache rooted $or queries that use clu... Backlog
is related to SERVER-76176 $text OR condition on phrases not wor... Closed
Assigned Teams:
Query Integration
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QI 2023-04-03, QI 2023-04-17, QI 2023-05-15, QI 2023-05-29, QI 2023-06-12, QI 2023-06-26
Participants:

 Description   

It appears that using $or to query both _id and a text index do not work together.

See this example:

db.createCollection('c', {clusteredIndex: {key: {_id: 1}, unique: true}})
db.c.createIndex({b: "text"})
db.c.insert({b: "foo"}
db.c.find({$or: [{$text: {$search: "foo"}}, {_id: 1}]})

This fails with the following error:

error processing query: ns=test.cTree: $or
    _id $eq 1
    TEXT : query=foo, language=english, caseSensitive=0, diacriticSensitive=0, tag=NULL
Sort: {}
Proj: {}
 planner returned error :: caused by :: Failed to produce a solution for TEXT under OR - other non-TEXT clauses under OR have to be indexed as well.



 Comments   
Comment by Githook User [ 16/Jun/23 ]

Author:

{'name': 'Gil Alon', 'email': 'gil.alon@mongodb.com', 'username': 'galon1'}

Message: SERVER-61259 Support or queries with text indexes on clustered collections
Branch: master
https://github.com/mongodb/mongo/commit/6b6a0c06d7b87c4bd408faad3730b7c19cc0f61a

Generated at Thu Feb 08 05:51:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.