/** * Returns a Lucene query to match documents by distance to a center, * relying first on spatial hash to approximate the result, and then on a more * precise (but more costly) {@link DistanceQuery}. * * @param center center of the search discus * @param radius distance max to center in km * @param fieldName name of the Lucene Field implementing Coordinates * @return Lucene Query to be used in a search * * @see Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildSpatialQueryByHash(Coordinates center, double radius, String fieldName) { return buildDistanceQuery( buildSpatialHashQuery( center, radius, fieldName ), center, radius, fieldName ); }
/** * Returns a Lucene query to match documents by distance to a center, * relying first on spatial hash to approximate the result, and then on a more * precise (but more costly) {@link DistanceQuery}. * * @param center center of the search discus * @param radius distance max to center in km * @param fieldName name of the Lucene Field implementing Coordinates * @return Lucene Query to be used in a search * * @see Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildSpatialQueryByHash(Coordinates center, double radius, String fieldName) { return buildDistanceQuery( buildSpatialHashQuery( center, radius, fieldName ), center, radius, fieldName ); }
session.clear(); luceneQuery = SpatialQueryBuilderFromCoordinates.buildSpatialHashQuery( center, radius, "location" ); hibQuery = fullTextSession.createFullTextQuery( luceneQuery, POI.class ); hibQuery.setProjection( "id", "name" );