This is my index 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<CustomerInvoice> { public InvoiceSummaryIndex() { Map = invoices => from invoice in invoices select new { DueDate = invoice.DueDate, DebtorId = invoice.DebtorId, Amount = invoice.Amount }; TransformResults = (database, results) => from invoice in results let debtor = database.Load<Debtor>(invoice.DebtorId) let company = database.Load<Company>(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 }; } }
And this is my request:
var query = from viewItem in session.Query<InvoiceSummaryView>("InvoiceSummaryIndex") where viewItem.CustomerId == id orderby viewItem.DueDate select viewItem;
error:
"Error": "System.ArgumentException: the field" CustomerId "is not indexed, cannot request fields that are not indexed ...
source share