Class: OpenSearch::DSL::Search::Filters::GeoDistance

Inherits:
Object
  • Object
show all
Includes:
BaseComponent
Defined in:
lib/opensearch/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.



73
74
75
76
# File 'lib/opensearch/dsl/search/filters/geo_distance.rb', line 73

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