Skip to content
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

PHPORM-277 Add Builder::vectorSearch() #3242

Merged
merged 2 commits into from
Jan 13, 2025
Merged

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Jan 9, 2025

Fix PHPORM-277

Adding the field vectorSearchScore by default, as this is a helpful and presented in the documentation.

For tests, the vectors are generated randomly, using a fixed seed.

Checklist

  • Add tests and ensure they pass

Sorry, something went wrong.

@GromNaN GromNaN requested a review from a team as a code owner January 9, 2025 12:41
@GromNaN GromNaN requested a review from jmikola January 9, 2025 12:41
@GromNaN GromNaN changed the title PHPORM-277 Add Builder::vectorSearch() PHPORM-277 Add Builder::vectorSearch() Jan 9, 2025
);
}

/** Generate random vectors */
Copy link
Member

@jmikola jmikola Jan 9, 2025

Choose a reason for hiding this comment

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

I think this comment would benefit from noting that you're using a fixed seed to make the tests deterministic.

Also, am I correct in assuming the vector4 generation here pertains to How to Ingest Pre-Quantized Vectors in the Atlas docs? That may be worth referencing as well.

{
srand(1);
foreach ($items as &$item) {
$this->vectors[] = $item['vector4'] = array_map(fn () => rand() / mt_getrandmax(), range(0, 3));
Copy link
Member

Choose a reason for hiding this comment

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

Consider leaving a TODO to revisit this once PHPC-2474 is implemented. It looks like that ticket entails more than just adding a new subtype constant, as there are utility functions to convert to/from vectors (as described in the corresponding spec).

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure for the todo, I create a ticket to add support in the aggregation builder first. https://jira.mongodb.org/browse/PHPLIB-1603

@GromNaN GromNaN enabled auto-merge (squash) January 13, 2025 16:40
@GromNaN GromNaN merged commit 35f4699 into mongodb:5.x Jan 13, 2025
29 of 32 checks passed
@GromNaN GromNaN deleted the PHPORM-277 branch January 13, 2025 16: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.

None yet

2 participants