使用:
如何使用多个参数进行搜索,如:
SELECT *
FROM example
WHERE column1 = "text1"
AND (column2 = "text2" OR column2 ="text3")
使用Hibernate-Search documentation我只找到了搜索示例:
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();
如果以某种方式存在,那将是完美的:
org.apache.lucene.search.Query query = parser.parse("column1: text1",
"column2: text2 | text3" );
另外,如果可以的话,很高兴知道如何搜索&#34; onlyOneword&#34;和#34;带有多个空格的文本&#34;
谢谢!
答案 0 :(得分:1)
尝试使用这样的BooleanQuery:
tasklist
它应该有用。