-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-1394: Support "type" option for createSearchIndex(es) #1375
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with an additional unit test for completeness.
The validation of this new option can be tested in SearchIndexInputTest
.
@jmikola can you please target v1.20 for this PR? No need to delay this functionality until 1.21 when we haven't released 1.20.0 yet. |
82161dd
to
f0be7e0
Compare
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Expected "type" option to have type "string"'); | ||
new SearchIndexInput(['definition' => ['mapping' => ['dynamic' => true]], 'type' => $type]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GromNaN: Added a unit test here and in CreateSearchIndexesTest
below. The test in the other file seems redundant, but we already had a test for name
so I thought it best to preserve the consistency.
2981a38
to
e2278c0
Compare
* ['definition' => ['mappings' => ['dynamic' => false, 'fields' => ['title' => ['type' => 'string']]]]], | ||
* // Create a named search index on all fields | ||
* ['name' => 'search_all', 'definition' => ['mappings' => ['dynamic' => true]]], | ||
* ]; | ||
* | ||
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/ | ||
* @see https://mongodb.com/docs/manual/reference/method/db.collection.createSearchIndex/ | ||
* @param list<array{name?: string, definition: array|object}> $indexes List of search index specifications | ||
* @param array{comment?: string} $options Command options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was originally typed as a string
in f6ce211, despite createSearchIndex()
correctly using mixed
for its option.
https://jira.mongodb.org/browse/PHPLIB-1394