Open timbonicus opened 12 years ago
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?
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.
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?
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?
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?