Hi guys,
I'm new to using Hibernate Search and I have no clue what I'm doing. I have an existing hibernate search query that I'm trying to change to that advantage of FullText query capabilities. My current query uses JOINs and I'm wondering how I can write JOIN queries with fullTextSession.createFullTextQuery().
Here's my current code:
Code:
queryStringBuff.append(" FROM Busines as B ");
queryStringBuff.append(" where B.Business_Id IN ( ");
queryStringBuff.append(" Select B.Business_Id from Busines as B ");
queryStringBuff.append(" JOIN Business_Address as BA ON B.Business_Id = BA.Business_Id");
queryStringBuff.append(" JOIN Address as A ON A.Address_Id = BA.Address_Id ");
queryStringBuff.append(" WHERE ");
queryStringBuff.append(" A.City_Name like '%" + criteria_.cityName + "%' ");
queryStringBuff.append(" and A.state = '" + criteria_.stateName + "')"
queryStringBuff.append(" AND ");
queryStringBuff.append(" ( ");
queryStringBuff.append(" B.Business_Name like '%" + criteria_.businessName + "%')" );
In this example, the 3 tables I need to join are BUSINESS, BUSINESS_ADDRESS, and ADRESS
And I have selected BUSINESS.Business_Name, ADDRESS.City_Name, ADDRESS.State and the 3 IDs as the indexed fields.
How can I change this to a FullTextQuery?
This is what I have so far:
Code:
FullTextSession fullTextSession = Search.createFullTextSession( this.getSession() );
MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[]{"businessName"}, new StandardAnalyzer());
org.apache.lucene.search.Query query = parser.parse(searchString);
searchQry = fullTextSession.createFullTextQuery(query, Business.class);
countQry = searchQry;
result = paginator.getPaginatdResult(session,countQry,searchQry,paginationControl_);
Unfortunately, they are NO examples on using JOINS out there!!! Please...Help!