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.


public IRavenQueryable<T> intersect();
Return Value
IRavenQueryable Instance implementing IRavenQueryable interface containing additional query methods.


// 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)