It is in the class QueryLoader, methode Load(), line 60 I don't know why but I think the prefered mechanism for filtering the result set in NH Search is to use Filters.
Simon On Tue, Dec 1, 2009 at 1:38 PM, gadlor <[email protected]> wrote: > Interesting! > > Fabio: Thanks for the link. I prefer to use NHSearch in this instance > because of the code annotations for indexing / flat file usage - the > database is large and I'd like to avoid putting indexes on it, > especially as the schema has a tendency to change semi-frequently. > > Simon: would it be possible to parameterize the QueryLoader so that it > accepts a conjunction / disjunction with a different restriction? It > seems ...restrictive :), to specifically limit what it can do, rather > than giving the consumers of the library the option of changing its > behavior. > > Could you give me a hint as to where I might find that disjunction in > the code? I'd like to take a look. > > Philip > > On Dec 1, 12:06 pm, Simon Laroche <[email protected]> wrote: > > Hi Philip > > > > The reason you can't filter with criteria is that the QueryLoader adds a > > disjunction to the criteria to load all the entities that are found in > the > > indexes with an IN restriction. > > > > Therefore, you could always use criteria to load more entities then the > > search would normally do but not less. > > > > Simon > > > > > > > > On Tue, Dec 1, 2009 at 10:20 AM, gadlor <[email protected]> > wrote: > > > 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]>> > > > <nhusers%[email protected]<nhusers%[email protected]> > <nhusers%252bunsubscr...@googlegroup s.com>> > > > > > . > > > > > 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]> > <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. > > > -- 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.
