http://nhforge.org/blogs/nhibernate/archive/2009/03/13/registering-freetext-or-contains-functions-into-a-nhibernate-dialect.aspx

2009/12/1 Fabio Maulo <[email protected]>

> You can use FullTextSearch even without NHSH.
> With Criteria creating 2 specific criterion (perhaps we should share ours
> in some place)
> With HQL registering two functions in the dialect (same of above).
>
> 2009/12/1 gadlor <[email protected]>
>
> Hi Simon,
>>
>> It does look like you can filter the result set returned by Criteria
>> with a full text query, though. I found this example in the test cases
>> of NHibernate.Search:
>>
>> [Test]
>> public void UsingCriteriaApi()
>> {
>>      IFullTextSession s = Search.CreateFullTextSession(OpenSession
>> ());
>>      ITransaction tx = s.BeginTransaction();
>>      Clock clock = new Clock(1, "Seiko");
>>      s.Save(clock);
>>      tx.Commit();
>>
>>      IList list = s.CreateCriteria(typeof(Clock))
>>      .Add(SearchRestrictions.Query("Brand:seiko"))
>>      .List();
>>      Assert.AreEqual(1, list.Count, "should get result back from
>> query");
>>
>>      s.Delete(clock);
>>      s.Flush();
>>      s.Close();
>>  }
>>
>> It took me a good bit of digging, but this does work. I suppose that
>> it's a little strange that it works only in one direction, but I'm not
>> going to complain too much.
>>
>> Is there a particular reason that Criteria can't filter full text
>> queries? Or just that it hasn't been properly implemented? I might
>> think of remedying the problem if it's just an issue of
>> implementation.
>>
>> Anyhow, hopefully this is useful to someone who ran into the same
>> problem I did.
>>
>> Thank you for your help!
>>
>> On Dec 1, 9:51 am, Simon Laroche <[email protected]> wrote:
>> > 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]>
>> <nhusers%[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]<nhusers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>>
>>
>
>
> --
> Fabio Maulo
>
>


-- 
Fabio Maulo

--

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