Class: Couchbase::Cluster::SearchQuery::GeoDistanceQuery

Inherits:
Couchbase::Cluster::SearchQuery show all
Defined in:
lib/couchbase/search_options.rb

Overview

Finds `geopoint` indexed matches around a point with the given distance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Couchbase::Cluster::SearchQuery

boolean_field, booleans, conjuncts, date_range, disjuncts, doc_id, geo_bounding_box, geo_distance, match, match_all, match_none, match_phrase, numeric_range, phrase, prefix, query_string, regexp, term, term_range, wildcard

Constructor Details

#initialize(longitude, latitude, distance) {|self| ... } ⇒ GeoDistanceQuery

Returns a new instance of GeoDistanceQuery.

Parameters:

  • longitude (Float)
  • latitude (Float)
  • distance (Float)

Yield Parameters:

[View source]

532
533
534
535
536
537
538
# File 'lib/couchbase/search_options.rb', line 532

def initialize(longitude, latitude, distance)
  super()
  @longitude = longitude
  @latitude = latitude
  @distance = distance
  yield self if block_given?
end

Instance Attribute Details

#boostFloat

Returns:

  • (Float)

523
524
525
# File 'lib/couchbase/search_options.rb', line 523

def boost
  @boost
end

#fieldString

Returns:

  • (String)

526
527
528
# File 'lib/couchbase/search_options.rb', line 526

def field
  @field
end

Instance Method Details

#to_json(*args) ⇒ String

Returns:

  • (String)
[View source]

541
542
543
544
545
546
547
548
549
# File 'lib/couchbase/search_options.rb', line 541

def to_json(*args)
  data = {
      "location" => [@longitude, @latitude],
      "distance" => @distance
  }
  data["boost"] = boost if boost
  data["field"] = field if field
  data.to_json(*args)
end