class Queries::GeoDistanceQueryBuilder
Constants
- DEFAULT_DISTANCE_UNIT
- NAME
Public Class Methods
new(field_name: @field_name = field_name)
click to toggle source
@params:
field_name: geo_point field in the document which is matched with the given query point: center point for this query distance: The radius of the circle centred on the specified location. Points which fall into this circle are considered to be matches. distance_unit: The distance can be specified in various units. See Distance Units. distance_type: How to compute the distance. Can either be arc (default), or plane (faster, but inaccurate on long distances and close to the poles) writable_name: Optional name field to identify the query validation_method: Set to IGNORE_MALFORMED to accept geo points with invalid latitude or longitude, set to COERCE to additionally try and infer correct coordinates (default is STRICT). ignore_unmapped: When set to true the ignore_unmapped option will ignore an unmapped field and will not match any documents for this query. When set to false (the default value) the query will throw an exception if the field is not mapped.
# File lib/queries/geo_distance_query_builder.rb, line 24 def initialize field_name: @field_name = field_name @point = nil @distance = nil @distance_unit = DEFAULT_DISTANCE_UNIT.distance_unit @distance_type = nil @writable_name = nil @validation_method = nil @ignore_unmapped = nil end
Public Instance Methods
distance(distance, distance_unit= nil)
click to toggle source
Sets distance and distance_unit
# File lib/queries/geo_distance_query_builder.rb, line 75 def distance distance, distance_unit= nil @distance = distance @distance_unit = distance_unit.distance_unit if distance_unit.present? return self end
distance_expr()
click to toggle source
Returns distance
# File lib/queries/geo_distance_query_builder.rb, line 65 def distance_expr return @distance end
distance_type(distance_type)
click to toggle source
Sets distance_type
# File lib/queries/geo_distance_query_builder.rb, line 87 def distance_type distance_type @distance_type = distance_type.distance_type return self end
distance_type_expr()
click to toggle source
Returns distance_type
# File lib/queries/geo_distance_query_builder.rb, line 82 def distance_type_expr return @distance_type end
distance_unit_expr()
click to toggle source
Returns distance_unit
# File lib/queries/geo_distance_query_builder.rb, line 70 def distance_unit_expr return @distance_unit end
field_name_expr()
click to toggle source
Returns field_name
# File lib/queries/geo_distance_query_builder.rb, line 60 def field_name_expr return @field_name end
ignore_unmapped(ignore_unmapped)
click to toggle source
Sets ignore_unmapped
# File lib/queries/geo_distance_query_builder.rb, line 120 def ignore_unmapped ignore_unmapped @ignore_unmapped = ignore_unmapped return self end
ignore_unmapped_expr()
click to toggle source
Returns ignore_unmapped
# File lib/queries/geo_distance_query_builder.rb, line 115 def ignore_unmapped_expr return @ignore_unmapped end
point(point)
click to toggle source
Sets point
# File lib/queries/geo_distance_query_builder.rb, line 54 def point point @point = point return self end
point_expr()
click to toggle source
Returns point
# File lib/queries/geo_distance_query_builder.rb, line 49 def point_expr return @point end
query()
click to toggle source
# File lib/queries/geo_distance_query_builder.rb, line 35 def query query = {} geo_query = self.common_query geo_query[@field_name] = @point.settings geo_query[:distance] = @distance.to_s + @distance_unit.to_s geo_query[:distance_type] = @distance_type geo_query[:writable_name] = @writable_name geo_query[:validation_method] = @validation_method geo_query[:ignore_unmapped] = @ignore_unmapped query[name.intern] = geo_query return query end
validation_method(validation_method)
click to toggle source
Sets validation_method
# File lib/queries/geo_distance_query_builder.rb, line 109 def validation_method validation_method @validation_method = validation_method.validation_method return self end
validation_method_expr()
click to toggle source
Returns validation_method
# File lib/queries/geo_distance_query_builder.rb, line 104 def validation_method_expr return @validation_method end
writable_name(writable_name)
click to toggle source
Sets writable_name
# File lib/queries/geo_distance_query_builder.rb, line 98 def writable_name writable_name @writable_name = writable_name return self end
writable_name_expr()
click to toggle source
Returns writable_name
# File lib/queries/geo_distance_query_builder.rb, line 93 def writable_name_expr return @writable_name end