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

PCBC-995: The SDK should throw an InvalidArgumentException when an empty VectorSearch is constructed #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Couchbase/VectorQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class VectorQuery
/**
* @param string $vectorFieldName the document field that contains the vector
* @param array<float>|string $vectorQuery the vector query to run. Cannot be empty. Either a vector array,
* or the vector query encoded into a base64 string.
* or a base64-encoded sequence of little-endian IEEE 754 floats.
*
* @since 4.1.7
*
Expand Down
6 changes: 6 additions & 0 deletions Couchbase/VectorSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Couchbase;

use Couchbase\Exception\InvalidArgumentException;
use JsonSerializable;

class VectorSearch implements JsonSerializable
Expand All @@ -31,12 +32,17 @@ class VectorSearch implements JsonSerializable
* @param array<VectorQuery> $vectorQueries The vector queries to be run.
* @param VectorSearchOptions|null $options The options to use on the vector queries
*
* @throws InvalidArgumentException
*
* @since 4.1.7
*
* @UNCOMMITTED: This API may change in the future.
*/
public function __construct(array $vectorQueries, VectorSearchOptions $options = null)
{
if (empty($vectorQueries)) {
throw new InvalidArgumentException("At least one vector query must be specified");
}
$this->vectorQueries = $vectorQueries;
$this->options = $options;
}
Expand Down
Loading