Does anyone have any familiarity with using Microsoft SQL Server 2005's Full Text search with NHibernate? Specifically, I want to be able to have my search results returned as the C# objects.
Right now I am solving the problem using CreateSQLQuery. Ideally I would solve this using HQL. The problem is further compounded my the fact that the class that I want to return is a subclass. This means particularly nasty queries of the form:
Code:
select {subclass.*} from subclass {subclass} join superclass as subclass_1_ on subclass_1_.guid = subclass.guid where (contains(content,:query)
As you can see I have had to hard code "subclass_1_" into the query. If you have any idea how to do this better, your help would be much appreciated.
Then I was trying to get it to work with HQL:
Code:
public class SQLServerDialectWithFTS : MsSql2005Dialect
{
public SQLServerDialectWithFTS()
: base()
{
RegisterFunction("CONTAINS", new StandardSQLFunction("CONTAINS", NHibernateUtil.Boolean));
RegisterFunction("FREETEXT", new StandardSQLFunction("FREETEXT", NHibernateUtil.Boolean));
}
}
and used the following HQL:
Code:
FROM Subclass sn WHERE CONTAINS(sn.Content,'asdf')
but this throws an exception:
Quote:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +7541816
NHibernate.Hql.Classic.WhereParser.CloseExpression(QueryTranslator q, String lcToken) +368
NHibernate.Hql.Classic.WhereParser.Token(String token, QueryTranslator q) +758
NHibernate.Hql.Classic.WhereParser.End(QueryTranslator q) +102
NHibernate.Hql.Classic.ClauseParser.EndChild(QueryTranslator q) +34
NHibernate.Hql.Classic.ClauseParser.End(QueryTranslator q) +50
NHibernate.Hql.Classic.PreprocessingParser.End(QueryTranslator q) +44
NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q) +232
NHibernate.Hql.Classic.QueryTranslator.Compile() +95
[QueryException: Incorrect query syntax [FROM DataAccessManager.Core.Domain.Subclass sn WHERE CONTAINS(sn.Content,'asdf')]]
NHibernate.Hql.Classic.QueryTranslator.Compile() +224
NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary replacements, Boolean scalar) +54
NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary enabledFilters) +135
NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar) +34
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results) +132
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters) +69
NHibernate.Impl.QueryImpl.List() +151
Any help would be appreciated.
Using NHibernate 1.2.1