Using:
- Hibernate 3.2.7.ga
- Hibernate-Search 3.0.0.ga
- Hibernate-Anotations 3.3.0.ga
- Hibernate-Commons-Cnnotations 3.0.0.ga
- Lucene-Core 2.9.4
- Lucene-Analyzers 2.9.4
- Lucene-Queryparser 2.9.4
How can search with multiple parameters like:
SELECT *
FROM example
WHERE column1 = "text1"
AND (column2 = "text2" OR column2 ="text3")
With Hibernate-Search documentation I only found that example of searching:
Session session = universalHibernateDAO.getHibernateSession();
FullTextSession fullTextSession = Search.createFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_29,
new String[]{"summary", "body"}, analyzer);
org.apache.lucene.search.Query query = parser.parse( "Java rocks!" );
Query hibQuery = fullTextSession.createFullTextQuery( query, PscpExpedient.class );
List<PscpExpedient> result = (List<PscpExpedient>)hibQuery.list();
tx.commit();
Will be perfect if exist some way to do something like:
org.apache.lucene.search.Query query = parser.parse("column1: text1",
"column2: text2 | text3" );
Also, if that is possible, will be nice to know how search "onlyOneword" and "text with multiple spaces"
Thanks!