2
我有多個實體存儲在一個單一的NHibernate搜索索引,希望我能夠一次查詢所有這些。用例是一個簡單的搜索頁面,它返回混合結果。因此,舉例來說,代碼看起來是這樣的:NHibernate搜索多態查詢
public interface ISearchable {}
[Indexed(Index = "TheIndex")]
public class SearchableEntityA : ISearchable
{
// Some [Field]s
}
[Indexed(Index = "TheIndex")]
public class SearchableEntityB : ISearchable
{
// Some other [Field]s
}
這一切指標正常,當然是可查詢的原始NHibernate的,像這樣:
session.CreateCriteria<ISearchable>().List<ISearchable>();
我有ISearchable某些領域,但這些在NHibernate映射中沒有特別引用。
我希望是,我可以只說:
var query = "some keyword";
fullTextSession.CreateFullTextQuery<ISearchable>(query).List<ISearchable>();
和檢索ISearchables的列表,包含來自各種不同的實體結果。然而,現實是它拋出了NHibernate.HibernateException: Not a mapped entity: NetComposites.Model.ISearchable
。
那麼,用NHibernate Search實現類似多態查詢的最簡單方法是什麼?