/** * Returns a Lucene query to match documents by distance to a center. * * @param center center of the search discus * @param radius distance max to center in km * @param coordinatesField name of the Lucene Field implementing Coordinates * @param approximationQuery an approximation of the distance query * (i.e. a query returning all the results returned by the distance query, * but also some false positives). * WARNING: when passing {@code null}, every single document will be scanned * (time/resource consuming!) * @return Lucene Query to be used in a search * * @see org.apache.lucene.search.Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildDistanceQuery(Query approximationQuery, Coordinates center, double radius, String coordinatesField) { return new DistanceQuery( approximationQuery, center, radius, coordinatesField ); }
/** * Returns a Lucene query to match documents by distance to a center. * * @param center center of the search discus * @param radius distance max to center in km * @param coordinatesField name of the Lucene Field implementing Coordinates * @param approximationQuery an approximation of the distance query * (i.e. a query returning all the results returned by the distance query, * but also some false positives). * WARNING: when passing {@code null}, every single document will be scanned * (time/resource consuming!) * @return Lucene Query to be used in a search * * @see org.apache.lucene.search.Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildDistanceQuery(Query approximationQuery, Coordinates center, double radius, String coordinatesField) { return new DistanceQuery( approximationQuery, center, radius, coordinatesField ); }
/** * Returns a Lucene query to match documents by distance to a center. * * @param center center of the search discus * @param radius distance max to center in km * @param latitudeField name of the Lucene Field hosting latitude * @param longitudeField name of the Lucene Field hosting longitude * @param approximationQuery an approximation of the distance query * (i.e. a query returning all the results returned by the distance query, * but also some false positives). * WARNING: when passing {@code null}, every single document will be scanned * (time/resource consuming!) * @return Lucene Query to be used in a search * * @see org.apache.lucene.search.Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildDistanceQuery(Query approximationQuery, Coordinates center, double radius, String latitudeField, String longitudeField) { return new DistanceQuery( approximationQuery, center, radius, latitudeField, longitudeField ); }
/** * Returns a Lucene query to match documents by distance to a center. * * @param center center of the search discus * @param radius distance max to center in km * @param latitudeField name of the Lucene Field hosting latitude * @param longitudeField name of the Lucene Field hosting longitude * @param approximationQuery an approximation of the distance query * (i.e. a query returning all the results returned by the distance query, * but also some false positives). * WARNING: when passing {@code null}, every single document will be scanned * (time/resource consuming!) * @return Lucene Query to be used in a search * * @see org.apache.lucene.search.Query * @see org.hibernate.search.spatial.Coordinates */ public static Query buildDistanceQuery(Query approximationQuery, Coordinates center, double radius, String latitudeField, String longitudeField) { return new DistanceQuery( approximationQuery, center, radius, latitudeField, longitudeField ); }
@Override public Query rewrite(IndexReader reader) throws IOException { Query superRewritten = super.rewrite( reader ); if ( superRewritten != this ) { return superRewritten; } Query rewrittenApproximationQuery = approximationQuery.rewrite( reader ); if ( rewrittenApproximationQuery != approximationQuery ) { DistanceQuery clone = new DistanceQuery( rewrittenApproximationQuery, this.center, this.radius, this.coordinatesField, this.latitudeField, this.longitudeField ); return clone; } return this; }
@Override public Query rewrite(IndexReader reader) throws IOException { Query superRewritten = super.rewrite( reader ); if ( superRewritten != this ) { return superRewritten; } Query rewrittenApproximationQuery = approximationQuery.rewrite( reader ); if ( rewrittenApproximationQuery != approximationQuery ) { DistanceQuery clone = new DistanceQuery( rewrittenApproximationQuery, this.center, this.radius, this.coordinatesField, this.latitudeField, this.longitudeField ); return clone; } return this; }