New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Atlas search index helpers to Models and Schemas #14251
Conversation
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 changes LGTM. Just FYI (re: CI) you can use the Atlas CLI to create a local Atlas deployment, which could be used for testing features such as this. |
@alexbevi that's really cool, thanks for the link. I don't think setting up a local Atlas deployment in CI should block releasing 8.1, so I'll merge this. But I'll look into local Atlas deployment in the future. |
Awesome Val. I just threw that out there as an FYI (not to hold anything up) |
added a separate discussion to not forget to consider adding atlas tests #14261 |
Support for MongoDB Atlas search indexes was added in [Automattic#14251](Automattic#14251) but the types for `Schema.searchIndex` and the `autoSearchIndex` option were missed. Add these types so that the typescript definitions match the capabilities of the JavaScript version of `mongoose`.
Support for MongoDB Atlas search indexes was added in [Automattic#14251](Automattic#14251) but the types for `Schema.searchIndex` and the `autoSearchIndex` option were missed. Add these types so that the typescript definitions match the capabilities of the JavaScript version of `mongoose`.
Support for MongoDB Atlas search indexes was added in [Automattic#14251](Automattic#14251) but the types for `Schema.searchIndex` and the `autoSearchIndex` option were missed. Add these types so that the typescript definitions match the capabilities of the JavaScript version of `mongoose`.
Summary
cc @alexbevi
Atlas search indexes are special indexes for Atlas text search. There's distinct functionality to create Atlas search indexes in the MongoDB Node driver, so I added the following functionality:
Model.createSearchIndex()
,Model.updateSearchIndex()
,Model.dropSearchIndex()
to wrap the MongoDB Node driver'sCollection.prototype.createSearchIndex()
, etc. functionsSchema.prototype.searchIndex()
autoSearchIndex
option analogous toautoIndex
that opts in to automatically creating search indexes. UnlikeautoIndex
,autoSearchIndex
is false by default.Here's an example of this code in action:
No tests right now because search indexes are only supported in MongoDB Atlas, and our CI tests don't run in Atlas. The MongoDB Node driver has a "manual" test suite that tests search indexes, something we should consider.
Examples