Skip to content

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

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Sep 5, 2024

Copy link
Member

@GromNaN GromNaN left a 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.

@alcaeus
Copy link
Member

alcaeus commented Sep 6, 2024

@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.

@jmikola jmikola changed the base branch from master to v1.20 September 6, 2024 13:12
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Expected "type" option to have type "string"');
new SearchIndexInput(['definition' => ['mapping' => ['dynamic' => true]], 'type' => $type]);
}
Copy link
Member Author

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.

@jmikola jmikola marked this pull request as ready for review September 6, 2024 17:43
@jmikola jmikola requested a review from a team as a code owner September 6, 2024 17:43
@jmikola jmikola requested a review from alcaeus September 6, 2024 17:43
* ['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
Copy link
Member Author

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.

@jmikola jmikola merged commit 99f3b77 into mongodb:v1.20 Sep 6, 2024
36 checks passed
@jmikola jmikola deleted the 1.20-phplib-1394 branch September 6, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants