Skip to content
This repository has been archived by the owner on Nov 3, 2018. It is now read-only.

Temporal Relationship Nt:Nt

mj1856 edited this page Jan 26, 2013 · 2 revisions

This is an example of an index with a NT:NT relationship. A department is indexed by its name and division name.

public class Departments_ByDivision : AbstractIndexCreationTask<Department, DepartmentWithDivision>
{
    public Departments_ByDivision()
    {
        Map = departments => 
        
        from department in departments
        let division = LoadDocument<Division>(department.DivisionId)
        select new
        {
            department.Name,
            Division = division.Name
        };

        // The division field is stored so we can return it in a projection.
        Store(x => x.Division, FieldStorage.Yes);
    }
}