Hi Philip,

Criteria cannot be used to filter the results of a full text query. In order
to filter a a full text query you need to define a filter:

var term = new Term("Engineer", "moi");
var filter = new QueryFilter(new TermQuery(term));
q.SetFilter(filter);

Simon


On Mon, Nov 30, 2009 at 4:49 PM, gadlor <[email protected]> wrote:

> Hello all,
>
> I wanted to check if anyone had tried using full text searches with
> NHibernate.Search in conjunction with ICriteria. I would like to
> restrict the set of results with ICriteria - rather than indexing all
> the properties of my objects.
>
> Here's what I'm attempting to do (I'm using ActiveRecord, btw):
>
> public static List<Thingy> GetThingyByDescription(string desc)
>    {
>        ISession session = ActiveRecordMediator.GetSessionFactoryHolder
> ().CreateSession(typeof(ActiveRecordBase));
>        IFullTextSession searchSession =
> NHibernate.Search.Search.CreateFullTextSession(session);
>        using (var transaction = searchSession.BeginTransaction())
>        {
>            List<Thingy> thingyList = new List<Thingy>();
>
>            IFullTextQuery q = (IFullTextQuery)
> searchSession.CreateFullTextQuery<Thingy>("Description:" + desc);
>            ICriteria thingyCriteria = searchSession.CreateCriteria
> (typeof(Thingy));
>            thingyCriteria.Add(Expression.Eq("Engineer", "moi"));
>            q.SetCriteriaQuery(thingyCriteria);
>
>            var results = q.List<Thingy>();  *******
>
>            foreach (Thingy t in results)
>            {
>                thingyList.Add(t);
>            }
>
>            return thingyList;
>        }
>    }
>
> I'm running into an issue, and I'm not precisely sure how to fix it.
>
> The call blows up with an exception at the line with all the
> asterisks:
>
> [TypeLoadException: Could not load type Thingy. Possible cause: no
> assembly name specified.]
>  NHibernate.Util.ReflectHelper.TypeFromAssembly
> (AssemblyQualifiedTypeName name, Boolean throwOnError) +329
>   NHibernate.Util.ReflectHelper.ClassForName(String name) +45
>   NHibernate.Search.Query.FullTextQueryImpl.GetLoader(ISession
> session) +285
>
> If I comment out the SetCriteria call, the search does its thing with
> no problems. The assembly is obviously accessible from the regular
> full text query.
>
> Has anybody done something like this successfully? Any insight into
> the exception? I've taken a look at the source and am going to try
> building NHibernate.Search with debug symbols so I can take a look at
> the 'AssemblyQualifiedTypeName,' but if there's anyone with knowledge
> of this firsthand, you will likely save me many frustrating hours.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to