This commit is contained in:
Vladyslav Vildanov
2023-03-27 17:07:03 +03:00
2 changed files with 9 additions and 5 deletions
@@ -12,7 +12,7 @@
namespace Predis\Command\Argument\Search\SchemaFields;
class VectorField implements FieldInterface
class VectorField extends AbstractField
{
/**
* @var array
@@ -23,13 +23,17 @@ class VectorField implements FieldInterface
* @param string $fieldName
* @param string $algorithm
* @param array $attributeNameValueDictionary
* @param string $alias
*/
public function __construct(
string $fieldName,
string $algorithm,
array $attributeNameValueDictionary
array $attributeNameValueDictionary,
string $alias = ''
) {
array_push($this->fieldArguments, $fieldName, 'VECTOR', $algorithm, count($attributeNameValueDictionary));
$this->setCommonOptions('VECTOR', $fieldName, $alias);
array_push($this->fieldArguments, $algorithm, count($attributeNameValueDictionary));
$this->fieldArguments = array_merge($this->fieldArguments, $attributeNameValueDictionary);
}
@@ -22,7 +22,7 @@ class VectorFieldTest extends TestCase
public function testReturnsCorrectFieldArgumentsArray(): void
{
$this->assertSame(
['field_name', 'VECTOR', 'FLAT', 2, 'attribute_name', 'attribute_value'],
(new VectorField('field_name', 'FLAT', ['attribute_name', 'attribute_value']))->toArray());
['field_name', 'AS', 'field', 'VECTOR', 'FLAT', 2, 'attribute_name', 'attribute_value'],
(new VectorField('field_name', 'FLAT', ['attribute_name', 'attribute_value'], 'field'))->toArray());
}
}