하나의 NHibernate Search 인덱스에 여러 엔티티가 저장되어있어 한꺼번에 질의 할 수 있기를 바랍니다. 유스 케이스는 혼합 된 결과를 반환하는 간단한 검색 페이지입니다.NHibernate Search를 이용한 다형성 질의
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로 다형성 질의와 비슷한 것을 얻을 수있는 가장 간단한 방법은 무엇입니까?