title: Why do I get this error in a RavenDB index query: The field 'CustomerId' is not indexed
body: <p>This is my index code:</p>
  
  <pre><code>public class InvoiceSummaryView
  {
      public DateTime DueDate { get; set; }
      public string CompanyAddress { get; set; }
      public string DebtorName { get; set; }
      public float Amount { get; set; }
      public bool IsPaid { get; set; }
      public string CustomerId { get; set; }
  }
  
  public class InvoiceSummaryIndex : AbstractIndexCreationTask&lt;CustomerInvoice&gt;
  {
      public InvoiceSummaryIndex()
      {
  
          Map = invoices =&gt; from invoice in invoices
                            select new { DueDate = invoice.DueDate, DebtorId = invoice.DebtorId, Amount = invoice.Amount };
  
          TransformResults = (database, results) =&gt;
              from invoice in results
              let debtor = database.Load&lt;Debtor&gt;(invoice.DebtorId)
              let company = database.Load&lt;Company&gt;(debtor.CompanyId)              
              select new {
                  DueDate = invoice.DueDate,
                  CompanyAddress = Company.Address.ToString(),
                  DebtorName = debtor.Contact.First + " " + debtor.Contact.Last,
                  Amount = invoice.Amount,
                  IsPaid = invoice.IsPaid,
                  CustomerId = Company.CustomerId
              };
  
      }
  }
  </code></pre>
  
  <p>And this is my query:</p>
  
  <pre><code>var query = from viewItem in session.Query&lt;InvoiceSummaryView&gt;("InvoiceSummaryIndex")
                          where viewItem.CustomerId == id
                          orderby viewItem.DueDate
                          select viewItem;
  </code></pre>
  
  <p>the error is: </p>
  
  <p>"Error": "System.ArgumentException: The field 'CustomerId' is not indexed, 
     cannot query on fields that are not indexed   at ...</p>