You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Querying: How to Use Intersect

To return only documents that match all provided sub-queries, use the intersect() method which enables RavenDB to perform server-side intersection queries.




// return all T-shirts that are manufactured by 'Raven'
// and contain both 'Small Blue' and 'Large Gray' types
const tShirts = await session
    .query({ indexName: "TShirts/ByManufacturerColorSizeAndReleaseYear" })
    .whereEquals("manufacturer", "Raven")
    .whereEquals("color", "Blue")
    .whereEquals("size", "Small")
    .whereEquals("color", "Gray")
    .whereEquals("size", "Large")
class TShirts_ByManufacturerColorSizeAndReleaseYearResult {
    constructor(data) {
        this.manufacturer = data.manufacturer;
        this.color = data.color;
        this.size = data.size;
        this.releaseYear = data.releaseYear;

class TShirts_ByManufacturerColorSizeAndReleaseYear extends AbstractIndexCreationTask {

    constructor() {
        super(); = `docs.TShirts.SelectMany(tshirt => tshirt.types, (tshirt, type) => new {
                manufacturer = tshirt.manufacturer,
                color = type.color,
                size = type.size,
                releaseYear = tshirt.releaseYear
from index 'TShirts/ByManufacturerColorSizeAndReleaseYear' 
where intersect(manufacturer = 'Raven', color = 'Blue' and size = 'Small', color = 'Gray' and size = 'Large')