$productId2 = Uuid::
randomHex();
$this->productRepository->
upsert([ ['id' =>
$productId1, 'productNumber' => Uuid::
randomHex(), 'stock' => 1, 'name' => 'test_product 1', 'price' =>
[['currencyId' => Defaults::CURRENCY, 'gross' => 10, 'net' => 9, 'linked' => false
]], 'tax' =>
['name' => 'test', 'taxRate' => 5
], 'manufacturer' =>
['name' => 'test'
]],
['id' =>
$productId2, 'productNumber' => Uuid::
randomHex(), 'stock' => 2, 'name' => 'test_product 2', 'price' =>
[['currencyId' => Defaults::CURRENCY, 'gross' => 10, 'net' => 9, 'linked' => false
]], 'tax' =>
['name' => 'test', 'taxRate' => 5
], 'manufacturer' =>
['name' => 'test'
]],
['id' => Uuid::
randomHex(), 'productNumber' => Uuid::
randomHex(), 'stock' => 1, 'name' => 'notmatch', 'price' =>
[['currencyId' => Defaults::CURRENCY, 'gross' => 10, 'net' => 9, 'linked' => false
]], 'tax' =>
['name' => 'notmatch', 'taxRate' => 5
], 'manufacturer' =>
['name' => 'notmatch'
]],
['id' => Uuid::
randomHex(), 'productNumber' => Uuid::
randomHex(), 'stock' => 1, 'name' => 'notmatch', 'price' =>
[['currencyId' => Defaults::CURRENCY, 'gross' => 10, 'net' => 9, 'linked' => false
]], 'tax' =>
['name' => 'notmatch', 'taxRate' => 5
], 'manufacturer' =>
['name' => 'notmatch'
]],
],
$this->context
);
$criteria =
new Criteria();
$criteria->
addFilter(new EqualsFilter('stock', 1
));
$criteria->
addQuery(new ScoreQuery(new ContainsFilter('manufacturer.name', 'test'
), 500
));
$criteria->
addQuery(new ScoreQuery(new ContainsFilter('name', 'test'
), 2500
));
$queries =
new CriteriaCollection([ 'product' =>
$criteria,
]);
$result =
$this->searcher->
search($queries,
$this->context
);
static::
assertCount(1,
$result);
static::
assertNotEmpty($result['product'
]);