Hi,
With Hibernate-search 4.2.0, I don't know how apply project on distance search.
Here is my code:
Code:
EntityManager em = emf.createEntityManager();
FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
try {
fullTextEntityManager.createIndexer().startAndWait();
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(MyisamProductArticleFacade.class.getName()).log(Level.SEVERE, null, ex);
}
String termsStr = terms.toLowerCase();
QueryBuilder qb = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity( MyisamProductArticle.class ).get();
org.apache.lucene.search.Query query = null;
query = qb
.bool()
.must(qb.keyword().onField("state").matching(state).createQuery())
.must(qb.keyword().onField("postcode").matching(postcode).createQuery())
.must(qb.spatial()
.onDefaultCoordinates()
.within( radius, Unit.KM )
.ofLatitude( lat )
.andLongitude( lon ).createQuery())
.createQuery();
Compared to the example given by http://docs.jboss.org/hibernate/search/4.2/reference/en-US/html/spatial.html :
Code:
FullTextQuery hibQuery = fullTextSession.createFullTextQuery(luceneQuery, POI.class);
query.setProjection(FullTextQuery.SPATIAL_DISTANCE, FullTextQuery.THIS);
query.setSpatialParameters(centerLatitude, centerLongitude, "location");
List results = hibQuery.list();
I don't know how to mix them together.
Any suggestion is very appreciated.
Thank you for the good work.
Samuel