我剛剛開始使用Raven,並且我創建的索引一直未能爲任何索引編制索引。我發現很多看起來像這樣的烏鴉服務器上的錯誤:RavenDB索引錯誤
{
Index: "HomeBlurb/IncludeTotalCosts",
Error: "Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)",
Timestamp: "2012-01-14T15:40:40.8943226Z",
Document: null
}
我創建看起來像這樣的指標:
public class HomeBlurb_IncludeTotalCosts : AbstractIndexCreationTask<MPDocument, HomeBlurb_IncludeTotalCosts.ReduceResult>
{
public class ReduceResult
{
public string Name { get; set; }
public string Constituency { get; set; }
public decimal AmountPaid { get; set; }
}
public HomeBlurb_IncludeTotalCosts()
{
Map = mps => from mp in mps
from expense in mp.Expenses
select new
{
mp.Name,
mp.Constituency,
AmountPaid = expense.AmountPaid ?? 0M
};
Reduce = results => from result in results
group result by new { result.Name, result.Constituency }
into g
select new
{
g.Key.Name,
g.Key.Constituency,
AmountPaid = g.Sum(x => x.AmountPaid)
};
}
}
該指數是由烏鴉創建(看它通過Raven Studio)並且看起來很好。
真正引發我的是,我使用的文件不包含任何雙打或整數,我存儲的唯一數字是小數。
什麼可能導致問題?
哪個構建您使用:
替換爲這個?我只是在一個使用573的小型演示中嘗試過你的索引,它沒有任何問題,沒有看到任何索引錯誤。 – 2012-01-14 16:24:50
我也使用573。 – ilivewithian 2012-01-14 16:44:25
我刪除並替換了所有的項目引用,重建客戶端,重新啓動服務器並重新導入數據,現在看起來一切正常。 – ilivewithian 2012-01-14 17:04:09