Skip to content

Commit

Permalink
throw invalid argument when empty vector search constructed (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Woz authored Jun 11, 2024
1 parent 998b6ac commit 0f9a2d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 0f9a2d2

Please # to comment.