Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fullText query of the index #11

Open
timbonicus opened this issue Sep 14, 2012 · 4 comments
Open

Add support for fullText query of the index #11

timbonicus opened this issue Sep 14, 2012 · 4 comments

Comments

@timbonicus
Copy link

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?

@mathpere
Copy link
Owner

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?

@timbonicus
Copy link
Author

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.

@mathpere
Copy link
Owner

mathpere commented Oct 1, 2012

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?

@timbonicus
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants