class Queries::GeoBoundingBoxQueryBuilder

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_bounding_box_query_builder.rb, line 24
def initialize field_name:
  @field_name = field_name
  @point = nil
  @distance = nil
  @distance_unit = DEFAULT_DISTANCE_UNIT.distance_unit
  @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_bounding_box_query_builder.rb, line 72
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_bounding_box_query_builder.rb, line 62
def distance_expr
  return @distance
end
distance_type(distance_type) click to toggle source

Sets distance_type

# File lib/queries/geo_bounding_box_query_builder.rb, line 84
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_bounding_box_query_builder.rb, line 79
def distance_type_expr
  return @distance_type
end
distance_unit_expr() click to toggle source

Returns distance_unit

# File lib/queries/geo_bounding_box_query_builder.rb, line 67
def distance_unit_expr
  return @distance_unit
end
field_name_expr() click to toggle source

Returns field_name

# File lib/queries/geo_bounding_box_query_builder.rb, line 57
def field_name_expr
  return @field_name
end
ignore_unmapped(ignore_unmapped) click to toggle source

Sets ignore_unmapped

# File lib/queries/geo_bounding_box_query_builder.rb, line 117
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_bounding_box_query_builder.rb, line 112
def ignore_unmapped_expr
  return @ignore_unmapped
end
point(point) click to toggle source

Sets point

# File lib/queries/geo_bounding_box_query_builder.rb, line 51
def point point
  @point = point
  return self
end
point_expr() click to toggle source

Returns point

# File lib/queries/geo_bounding_box_query_builder.rb, line 46
def point_expr
  return @point
end
query() click to toggle source
# File lib/queries/geo_bounding_box_query_builder.rb, line 34
def query
  query = {}
  geo_query = self.common_query
  geo_query[@field_name] = @point.settings
  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_bounding_box_query_builder.rb, line 106
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_bounding_box_query_builder.rb, line 101
def validation_method_expr
  return @validation_method
end
writable_name(writable_name) click to toggle source

Sets writable_name

# File lib/queries/geo_bounding_box_query_builder.rb, line 95
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_bounding_box_query_builder.rb, line 90
def writable_name_expr
  return @writable_name
end