Session: Querying: How to use intersect?
To return only documents that match all provided sub-queries we have introduced intersect
extension that enables us to do server-side intersection queries.
Syntax
public IRavenQueryable<T> intersect();
Return Value | |
---|---|
IRavenQueryable | Instance implementing IRavenQueryable interface containing additional query methods. |
Example
// return all T-shirts that are manufactured by 'Raven'
// and contain both 'Small Blue' and 'Large Gray' types
QIntersection_TShirt t = QIntersection_TShirt.tShirt;
QIntersection_TShirtType tt = QIntersection_TShirtType.tShirtType;
List<TShirt> tshirts = session
.query(TShirt.class, TShirts_ByManufacturerColorSizeAndReleaseYear.class)
.where(t.manufacturer.eq("Raven"))
.intersect()
.where(t.types.any(tt.color.eq("Blue").and(tt.size.eq("Small"))))
.intersect()
.where(t.types.any(tt.color.eq("Gray").and(tt.size.eq("Large"))))
.toList();