Class: Elasticsearch::DSL::Search::Filters::GeoDistance

Inherits:
Object
  • Object
show all
Includes:
BaseComponent
Defined in:
lib/elasticsearch/dsl/search/filters/geo_distance.rb

Overview

A filter which returns documents which fall into a specified geographical distance

See the integration test for a working example.

Examples:

Define the filter with a hash


search do
  query do
    filtered do
      filter do
        geo_distance location: '50.090223,14.399590', distance: '5km'
      end
    end
  end
end

Define the filter with a block


search do
  query do
    filtered do
      filter do
        geo_distance :location do
          lat '50.090223'
          lon '14.399590'
          distance '5km'
        end
      end
    end
  end
end

See Also:

Instance Method Summary collapse

Methods included from BaseComponent

included

Constructor Details

#initialize(*args, &block) ⇒ GeoDistance

Returns a new instance of GeoDistance.



65
66
67
68
# File 'lib/elasticsearch/dsl/search/filters/geo_distance.rb', line 65

def initialize(*args, &block)
  super
  @hash[self.name.to_sym] = { @args => {} } unless @args.empty?
end