I have multiple entities stored in a single NHibernate Search index, in the hope that I'd be able to query over all of them at once. The use case is a simple search page which returns mixed results. So, for example, the code could look like this:
public interface ISearchable {}
[Indexed(Index = "TheIndex")]
public class SearchableEntityA : ISearchable
{
// Some [Field]s
}
[Indexed(Index = "TheIndex")]
public class SearchableEntityB : ISearchable
{
// Some other [Field]s
}
This all indexes fine, and of course is queryable in raw NHibernate like so:
session.CreateCriteria<ISearchable>().List<ISearchable>();
I have some fields on ISearchable, but these aren't specifically referenced in NHibernate mappings.
My hope was that I could just say:
var query = "some keyword";
fullTextSession.CreateFullTextQuery<ISearchable>(query).List<ISearchable>();
And retrieve a list of ISearchables, containing results from various different entities. However, the reality is that it throws NHibernate.HibernateException: Not a mapped entity: NetComposites.Model.ISearchable
.
So, what's the simplest way to achieve something resembling polymorphic queries with NHibernate Search?