Skip to content

GODRIVER-3125 Allow to set search index type #1649

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

Merged
merged 11 commits into from
Jun 3, 2024

Conversation

blink1073
Copy link
Member

GODRIVER-3125

Summary

Add the ability to pick the search index type when creating a new search index.

Background & Motivation

Drivers must support use of the type field when creating search indexes. Creating a vector search index requires specifying type=vectorSearch.

Copy link
Contributor

API Change Report

./mongo/options

compatible changes

(*SearchIndexesOptions).SetType: added
SearchIndexesOptions.Type: added

blink1073 and others added 5 commits May 31, 2024 15:07
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
@blink1073 blink1073 requested a review from prestonvasquez May 31, 2024 20:08
@@ -26,7 +26,7 @@ tests:
- name: createSearchIndex
object: *collection0
arguments:
model: { definition: &definition { mappings: { dynamic: true } } }
model: { definition: &definition { mappings: { dynamic: true } } , type: 'search' }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are failing because we do not include Type in executeCreateSearchIndexes and executeCreateSearchIndex operations. This can be fixed by updating the case here and here to include Type. e.g.

var m struct {
	Definition interface{}
	Name       *string
	Type *string
}
err = bson.Unmarshal(val.Value, &m)
if err != nil {
	return nil, err
}
model := mongo.SearchIndexModel{
	Definition: m.Definition,
	Options:    options.SearchIndexes(),
}
model.Options.Name = m.Name
model.Options.Type = m.Type
models = append(models, model)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


mt.RunOpts("case 7: Driver can successfully handle search index types when creating indexes",
mtest.NewOptions().CollectionName(case7CollName.String()),
func(mt *mtest.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized this change requires everything after this line to be indented, my suggestion didn't include that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


mt.RunOpts("case 8: Driver requires explicit type to create a vector search index",
mtest.NewOptions().CollectionName(case8CollName.String()),
func(mt *mtest.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized this change requires everything after this line to be indented, my suggestion didn't include that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@blink1073 blink1073 requested a review from prestonvasquez June 3, 2024 12:52
@blink1073 blink1073 merged commit 0f10f5e into mongodb:v1 Jun 3, 2024
24 of 26 checks passed
@blink1073 blink1073 deleted the GODRIVER-3125 branch June 3, 2024 17:50
blink1073 added a commit to blink1073/mongo-go-driver that referenced this pull request Jun 3, 2024
Co-authored-by: Jeroen Vervaeke <jeroen.vervaeke@mongodb.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
(cherry picked from commit 0f10f5e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants