Using Intersect
To return only documents that match all provided sub-queries, use the
intersect
extension to allow RavenDB to perform server-side intersection queries.
Syntax
public function intersect(): DocumentQueryInterface;
Example
// return all T-shirts that are manufactured by 'Raven'
// and contain both 'Small Blue' and 'Large Gray' types
/** @var array<TShirt> $tShirts */
$tShirts = $session
->query(TShirt::class, TShirts_ByManufacturerColorSizeAndReleaseYear::class)
->whereEquals("manufacturer", "Raven")
->intersect()
->whereEquals("color", "Blue")
->andAlso()
->whereEquals("size", "Small")
->intersect()
->whereEquals("color", "Gray")
->andAlso()
->whereEquals("size", "Large")
->toList();
from index 'TShirts/ByManufacturerColorSizeAndReleaseYear'
where intersect(Manufacturer = 'Raven', Color = 'Blue' and Size = 'Small', Color = 'Gray' and Size = 'Large')