views:

73

answers:

1

How to use 2nd Level Cache with NHibernate.Search ?

I tried to enable SetCacheable on FullTextQuery, but it doesn't work.

        var session = Search.CreateFullTextSession(database.Session);

        session.CacheMode = CacheMode.Normal;

        var textQuery = session.CreateFullTextQuery(query, new[] { typeof(Job) });

        textQuery.SetCacheable(true);
        textQuery.SetCacheRegion("Job");

        var jobs = textQuery.List<Job>();

        return jobs;

For all other standard queries tha cache works well but with FullTextQueries, it doesn't, NHibernate.Search still hit my database.

Note that NHibernate.Search produced queries are SELECT ... WHERE EntityId IN (Id1,Id2,Id3,...)

+1  A: 

are you sure that your entities are in the 2nd level cache. Normally you have to be working and querying within transactions in order for the 2nd level cache to do anything.

Andrew Smith
The only one way i founded is to specify a criteria to the nhibernate fulltextquery ...
Yoann. B