[SERVER-60474] Better error message for $search when there is no search index Created: 05/Oct/21  Updated: 29/Oct/23  Resolved: 06/Feb/23

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

Type: Improvement Priority: Minor - P4
Reporter: Oren Ovadia Assignee: Jacob Evans
Resolution: Fixed Votes: 1
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Participants:

 Description   

When running a $search on a community edition of mongodb we get the following error:

> db.fts.aggregate([{$search:{}}])
2021-10-05T11:33:22.188-0700 E  QUERY    [js] uncaught exception: Error: command failed: {
        "ok" : 0,
        "errmsg" : "Unrecognized pipeline stage name: '$search'",
        "code" : 40324,
        "codeName" : "Location40324"
} : aggregate failed : 

Instead we would want to have a more descriptive error message that $search is only available in Atlas.

 

marcus.eagan, FYI. Also I have marked this as low priority.



 Comments   
Comment by James Wahlin [ 10/May/23 ]

alice.neff@mongodb.com that is correct. This error message change is on version 6.2 and newer of the server. Let us know if you would like to request a backport to earlier versions.

Comment by Alice Neff [ 10/May/23 ]

james.wahlin@mongodb.com - since I do not see any linked backport tickets, can assume this has not been backported to 6.0 and 5.0?

cc ksenia.samokhvalova@mongodb.com elle.shwer@mongodb.com amy.jian@mongodb.com

Comment by Githook User [ 04/Nov/22 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-60474 Change error message for $search without search enabled
Branch: master
https://github.com/mongodb/mongo/commit/805171eb5b013dd36e5f1b9aca6fd25fba3b38e6

Comment by Marcus Eagan (Inactive) [ 04/Oct/22 ]

The error for EA seems obtuse and less explicit. I understand there are correctness constraints.

Comment by Amy Jian [ 04/Oct/22 ]

ted.tuckman@mongodb.com I'm not familiar if there is a common way to we refer to Atlas in community, but the new error message LGTM! 

For reference, what is the message for enterprise, non-Atlas users for this? 

Comment by Amy Jian [ 04/Oct/22 ]

ted.tuckman@mongodb.com I noticed in the PR that the error message will be "Search stages are not allowed without the enterprise module". To clarify, $search and $searchMeta is only available to Atlas customers - I want to confirm that this error accurately reflects that constraint since my own reaction to the proposed messaging is that it sounds like you need to be on EA for it to work (which we do not support).    

Comment by Marcus Eagan (Inactive) [ 15/Sep/22 ]

sgtm

Comment by Elle Shwer [ 14/Sep/22 ]

Might I suggest we break this into two tickets:

1. Returning a more useful error for community users who try search (this ticket)
2. Returning a more useful error for users who write a query where the search index does not exist (is that addressed by server or search?)

And then the component about " empty array/test environment" I think requires more research on how valuable that might be. cc ruchir.mehta@mongodb.com

Comment by Oren Ovadia [ 13/Sep/22 ]

FYI: evan.plotkin@mongodb.com 

Comment by Marcus Eagan (Inactive) [ 23/Feb/22 ]

our growth has been hindered by the fact users cannot run the $search stage locally or in their managed environments. cailin.nelson had an interesting idea of returning an empty array so we don't break people's build pipelines. Maybe we can consider returning an empty array when customers don't have an Atlas cluster.

Comment by Asya Kamsky [ 15/Feb/22 ]

marcus.eagan so for community and EA (not Atlas) the error should be "$search requires Atlas TFS index" - with or without additional phrase "and it's not found"?

Because of sharding issues, I think error for Atlas $search when index is not found should be handled separately (and tracked in a separate ticket).

 

Comment by Marcus Eagan (Inactive) [ 15/Feb/22 ]

I think the error you have posted is good asya, as Googling it surfaces the appropriate link, which is what developers do with errors, and the api resource is `fts`. I would not worry too much about the breaking change, though we do need to explicitly state it as such, because this is a breaking change on an error.

Comment by Asya Kamsky [ 14/Feb/22 ]

There seem to be three different issues when running $search, one in Atlas without text index created, one in EA (gives misleading/confusing error message), and in community (gives a possibly confusing error message that's different than EA message).

I'd like to re-purpose this ticket to fix all of them.

Comment by Anton Korshunov [ 11/Feb/22 ]

When executed on Enterprise build the following error message is returned:

 

db.coll.aggregate([{$search:{}}])
uncaught exception: Error: command failed: {
 "ok" : 0,
 "errmsg" : "PlanExecutor error during aggregation :: caused by :: $search not enabled! Enable Search by setting serverParameter mongotHost to a valid \"host:port\" string",
 "code" : 31082,
 "codeName" : "Location31082"
} with original command request: {
 "aggregate" : "coll",
 "pipeline" : [
 {
 "$search" : {
}
 }
 ],
 "cursor" : {
},
 "lsid" : {
 "id" : UUID("6659aefc-119a-42fd-aece-1f901ca08236")
 }
}

 

Comment by David Storch [ 08/Feb/22 ]

Returning this to the QO team's triage queue, as it ended up in the "unassigned" state,

Comment by Oren Ovadia [ 14/Dec/21 ]

Got it.
In that case, the distinction does matter.
An enterprise version of mongod may support the `$search` stage, but `$search` can only work in Atlas

Comment by Billy Donahue [ 14/Dec/21 ]

> Are enterprise builds only available on Atlas?

Definitely not.
There are heaps of non-Atlas enterprise installations.

Comment by Oren Ovadia [ 14/Dec/21 ]

Are enterprise builds only available on Atlas?
(Also note that this is meant to be a user facing error)

Comment by Oren Ovadia [ 06/Dec/21 ]

Thanks Ribhav

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