grails-hibernate-search-plugin icon indicating copy to clipboard operation
grails-hibernate-search-plugin copied to clipboard

Add support for fullText query of the index

Open timbonicus opened this issue 12 years ago • 4 comments

The plugin adds search methods to domain classes, but behind the scenes a full-text index is built. Is there a way to easily search across all indexed domain classes - or better, a provided list of domain classes?

timbonicus avatar Sep 14 '12 22:09 timbonicus

Hibernate Search does not seem to provide a way to search accross all indexed domain classes unless I am missing something. Could you give any further informations about your use case?

mathpere avatar Sep 23 '12 15:09 mathpere

The documentation seems to mention the capability:

If not specified otherwise, the query will be executed against all indexed entities, potentially returning all types of indexed classes.

My particular use case is to have several types of entities indexed in the system and provide a global search function that crosses all indexed domain classes.

timbonicus avatar Oct 01 '12 15:10 timbonicus

Ok, I got your point.

Of course, it is possible to get your own fullTextSession and use Hibernate Search as explained in the doc:


class MyService {

    def sessionFactory

    def searchAccrossItemAndActor( /* ... */ ) {

        def hibernateTemplate = new HibernateTemplate( sessionFactory )

        hibernateTemplate.execute( { Session session ->

            FullTextSession fullTextSession = Search.getFullTextSession( session )
            fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery, Item, Actor )

            /* ... */

        } as HibernateCallback )
    }
}

Currently, the plugin lets you to search for an individual domain class:

MyDomainClass.search().list {
// query
}

(Which facilitates the same kind of code for a domain class.)

Do you think of a particular way the plugin would make it easy?

mathpere avatar Oct 01 '12 18:10 mathpere

Hmm, it's a good question. My initial thinking was something like:

FullTextSession.search(DomainClass1, DomainClass2, DomainClass3).list {
    // query
}

Granted, I was just evaluating the plugin for inclusion in my project so I'm not very familiar with the classes and syntax. Any thoughts?

timbonicus avatar Oct 01 '12 19:10 timbonicus