Class: Couchbase::SearchQuery::GeoPolygonQuery

Inherits:
SearchQuery
  • Object
show all
Defined in:
lib/couchbase/search_options.rb

Overview

A search query which allows to match inside a geo polygon.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coordinates) {|self| ... } ⇒ GeoPolygonQuery

Returns a new instance of GeoPolygonQuery.

Parameters:

  • coordinates (Array<Coordinate>)

    list of coordinates that forms polygon

Yield Parameters:



708
709
710
711
712
# File 'lib/couchbase/search_options.rb', line 708

def initialize(coordinates)
  super()
  @coordinates = coordinates
  yield self if block_given?
end

Instance Attribute Details

#boostFloat

Returns:

  • (Float)


700
701
702
# File 'lib/couchbase/search_options.rb', line 700

def boost
  @boost
end

#fieldString

Returns:

  • (String)


703
704
705
# File 'lib/couchbase/search_options.rb', line 703

def field
  @field
end

Instance Method Details

#to_hHash<Symbol, #to_json>

Returns:



715
716
717
718
719
720
721
722
# File 'lib/couchbase/search_options.rb', line 715

def to_h
  data = {
    :polygon_points => @coordinates.map { |coord| [coord.longitude, coord.latitude] },
  }
  data[:boost] = boost if boost
  data[:field] = field if field
  data
end