erichummel-sunspot 1.2.1 → 2.0.0.pre.111215

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gitignore +0 -1
  2. data/Gemfile +2 -1
  3. data/History.txt +30 -0
  4. data/Rakefile +5 -9
  5. data/lib/sunspot.rb +13 -3
  6. data/lib/sunspot/batcher.rb +62 -0
  7. data/lib/sunspot/class_set.rb +23 -0
  8. data/lib/sunspot/configuration.rb +7 -0
  9. data/lib/sunspot/dsl.rb +1 -1
  10. data/lib/sunspot/dsl/field_group.rb +57 -0
  11. data/lib/sunspot/dsl/field_query.rb +48 -0
  12. data/lib/sunspot/dsl/function.rb +13 -0
  13. data/lib/sunspot/dsl/paginatable.rb +5 -1
  14. data/lib/sunspot/dsl/restriction_with_near.rb +39 -0
  15. data/lib/sunspot/dsl/scope.rb +4 -4
  16. data/lib/sunspot/dsl/search.rb +2 -2
  17. data/lib/sunspot/dsl/standard_query.rb +2 -0
  18. data/lib/sunspot/indexer.rb +12 -7
  19. data/lib/sunspot/query.rb +3 -3
  20. data/lib/sunspot/query/bbox.rb +15 -0
  21. data/lib/sunspot/query/common_query.rb +13 -2
  22. data/lib/sunspot/query/dismax.rb +5 -1
  23. data/lib/sunspot/query/field_group.rb +36 -0
  24. data/lib/sunspot/query/geofilt.rb +16 -0
  25. data/lib/sunspot/query/highlighting.rb +8 -1
  26. data/lib/sunspot/query/pagination.rb +8 -4
  27. data/lib/sunspot/query/sort.rb +14 -0
  28. data/lib/sunspot/query/sort_composite.rb +3 -2
  29. data/lib/sunspot/search.rb +1 -1
  30. data/lib/sunspot/search/abstract_search.rb +53 -65
  31. data/lib/sunspot/search/field_group.rb +32 -0
  32. data/lib/sunspot/search/group.rb +50 -0
  33. data/lib/sunspot/search/hit.rb +21 -7
  34. data/lib/sunspot/search/hit_enumerable.rb +72 -0
  35. data/lib/sunspot/search/paginated_collection.rb +5 -3
  36. data/lib/sunspot/session.rb +3 -1
  37. data/lib/sunspot/type.rb +21 -0
  38. data/lib/sunspot/util.rb +9 -0
  39. data/lib/sunspot/version.rb +1 -1
  40. data/spec/api/batcher_spec.rb +112 -0
  41. data/spec/api/class_set_spec.rb +24 -0
  42. data/spec/api/hit_enumerable_spec.rb +47 -0
  43. data/spec/api/indexer/batch_spec.rb +29 -3
  44. data/spec/api/query/function_spec.rb +9 -0
  45. data/spec/api/query/group_spec.rb +32 -0
  46. data/spec/api/query/highlighting_examples.rb +22 -0
  47. data/spec/api/query/ordering_pagination_examples.rb +21 -0
  48. data/spec/api/query/spatial_examples.rb +27 -0
  49. data/spec/api/query/standard_spec.rb +1 -0
  50. data/spec/api/search/hits_spec.rb +11 -0
  51. data/spec/api/search/paginated_collection_spec.rb +10 -0
  52. data/spec/api/search/results_spec.rb +6 -0
  53. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +0 -11
  54. data/spec/api/session_spec.rb +12 -0
  55. data/spec/api/sunspot_spec.rb +11 -0
  56. data/spec/helpers/indexer_helper.rb +0 -12
  57. data/spec/helpers/integration_helper.rb +8 -0
  58. data/spec/helpers/mock_session_helper.rb +13 -0
  59. data/spec/helpers/query_helper.rb +0 -12
  60. data/spec/helpers/search_helper.rb +0 -12
  61. data/spec/integration/dynamic_fields_spec.rb +2 -0
  62. data/spec/integration/faceting_spec.rb +14 -1
  63. data/spec/integration/field_grouping_spec.rb +66 -0
  64. data/spec/integration/geospatial_spec.rb +85 -0
  65. data/spec/integration/highlighting_spec.rb +22 -0
  66. data/spec/integration/indexing_spec.rb +23 -1
  67. data/spec/integration/keyword_search_spec.rb +1 -1
  68. data/spec/integration/local_search_spec.rb +1 -1
  69. data/spec/integration/more_like_this_spec.rb +1 -1
  70. data/spec/integration/scoped_search_spec.rb +1 -1
  71. data/spec/integration/stored_fields_spec.rb +2 -0
  72. data/spec/integration/test_pagination.rb +13 -2
  73. data/spec/integration/unicode_spec.rb +15 -0
  74. data/spec/mocks/connection.rb +4 -4
  75. data/spec/mocks/post.rb +1 -0
  76. data/spec/spec_helper.rb +21 -11
  77. data/sunspot.gemspec +42 -0
  78. data/tasks/rdoc.rake +2 -2
  79. metadata +95 -135
  80. data/VERSION.yml +0 -4
  81. data/bin/sunspot-installer +0 -19
  82. data/bin/sunspot-solr +0 -74
  83. data/installer/config/schema.yml +0 -95
  84. data/lib/sunspot/installer.rb +0 -31
  85. data/lib/sunspot/installer/library_installer.rb +0 -45
  86. data/lib/sunspot/installer/schema_builder.rb +0 -219
  87. data/lib/sunspot/installer/solrconfig_updater.rb +0 -76
  88. data/lib/sunspot/installer/task_helper.rb +0 -18
  89. data/lib/sunspot/server.rb +0 -152
  90. data/solr-1.3/etc/jetty.xml +0 -212
  91. data/solr-1.3/etc/webdefault.xml +0 -379
  92. data/solr-1.3/lib/jetty-6.1.3.jar +0 -0
  93. data/solr-1.3/lib/jetty-util-6.1.3.jar +0 -0
  94. data/solr-1.3/lib/jsp-2.1/ant-1.6.5.jar +0 -0
  95. data/solr-1.3/lib/jsp-2.1/core-3.1.1.jar +0 -0
  96. data/solr-1.3/lib/jsp-2.1/jsp-2.1.jar +0 -0
  97. data/solr-1.3/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
  98. data/solr-1.3/lib/servlet-api-2.5-6.1.3.jar +0 -0
  99. data/solr-1.3/solr/conf/elevate.xml +0 -36
  100. data/solr-1.3/solr/conf/protwords.txt +0 -21
  101. data/solr-1.3/solr/conf/schema.xml +0 -64
  102. data/solr-1.3/solr/conf/solrconfig.xml +0 -725
  103. data/solr-1.3/solr/conf/stopwords.txt +0 -57
  104. data/solr-1.3/solr/conf/synonyms.txt +0 -31
  105. data/solr-1.3/solr/lib/geoapi-nogenerics-2.1-M2.jar +0 -0
  106. data/solr-1.3/solr/lib/gt2-referencing-2.3.1.jar +0 -0
  107. data/solr-1.3/solr/lib/jsr108-0.01.jar +0 -0
  108. data/solr-1.3/solr/lib/locallucene.jar +0 -0
  109. data/solr-1.3/solr/lib/localsolr.jar +0 -0
  110. data/solr-1.3/start.jar +0 -0
  111. data/solr-1.3/webapps/solr.war +0 -0
  112. data/solr/README.txt +0 -42
  113. data/solr/etc/jetty.xml +0 -218
  114. data/solr/etc/webdefault.xml +0 -379
  115. data/solr/lib/jetty-6.1.3.jar +0 -0
  116. data/solr/lib/jetty-util-6.1.3.jar +0 -0
  117. data/solr/lib/jsp-2.1/ant-1.6.5.jar +0 -0
  118. data/solr/lib/jsp-2.1/core-3.1.1.jar +0 -0
  119. data/solr/lib/jsp-2.1/jsp-2.1.jar +0 -0
  120. data/solr/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
  121. data/solr/lib/servlet-api-2.5-6.1.3.jar +0 -0
  122. data/solr/solr/.gitignore +0 -1
  123. data/solr/solr/README.txt +0 -54
  124. data/solr/solr/conf/admin-extra.html +0 -31
  125. data/solr/solr/conf/elevate.xml +0 -36
  126. data/solr/solr/conf/mapping-ISOLatin1Accent.txt +0 -246
  127. data/solr/solr/conf/protwords.txt +0 -21
  128. data/solr/solr/conf/schema.xml +0 -238
  129. data/solr/solr/conf/scripts.conf +0 -24
  130. data/solr/solr/conf/solrconfig.xml +0 -934
  131. data/solr/solr/conf/spellings.txt +0 -2
  132. data/solr/solr/conf/stopwords.txt +0 -58
  133. data/solr/solr/conf/synonyms.txt +0 -31
  134. data/solr/solr/conf/xslt/example.xsl +0 -132
  135. data/solr/solr/conf/xslt/example_atom.xsl +0 -67
  136. data/solr/solr/conf/xslt/example_rss.xsl +0 -66
  137. data/solr/solr/conf/xslt/luke.xsl +0 -337
  138. data/solr/start.jar +0 -0
  139. data/solr/webapps/solr.war +0 -0
  140. data/spec/api/server_spec.rb +0 -91
  141. data/spec/integration/spec_helper.rb +0 -7
data/.gitignore CHANGED
@@ -6,7 +6,6 @@ pkg
6
6
  .DS_Store
7
7
 
8
8
  .yardoc
9
- sunspot.gemspec
10
9
  README.rdoc
11
10
  .bundle
12
11
  Gemfile.lock
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in carrierwave_backgrounder.gemspec
3
+ gem 'sunspot_solr', :path => File.expand_path('../../sunspot_solr', __FILE__)
4
+
4
5
  gemspec
@@ -1,3 +1,33 @@
1
+ == 2.0.0
2
+ * Adds support for field grouping (Andy Lindeman)
3
+ * Adds support for native geospatial searches and ordering (Eric Tang, Bruno Miranda, Andy Lindeman)
4
+ * Bundled Solr installation (`sunspot_solr`) is version 3.5.0 (Chris Parker)
5
+ * Adds #query_time method to retrieve the Solr query time in
6
+ milliseconds (Jason Weathered)
7
+ * Fixes syntax of highlighting when used with nested dismax queries (Marco Crepaldi)
8
+ * Adds ability to nest `Sunspot.batch` calls (Thorbjørn Hermansen)
9
+ * Adds `open_timeout` and `read_timeout` configuration options (Rob Di
10
+ Marco)
11
+
12
+ == 1.3.0 2011-11-26
13
+ * Requests to Solr use HTTP POST verb by default to avoid issues when the query string grows too large for GET (Johan Van Ryseghem)
14
+ * `sunspot.yml` supports ERB (Andrew Cholakian)
15
+ * An error is raised when attempting to run the packaged Solr if Java is not available (Lucas Parry)
16
+ * Pagination operates correctly without dependency on `will_paginate` (Larry Sprock, Dave Krupinski)
17
+ * Stored boolean fields with `false` value are returned correctly (yipdw)
18
+ * `highlight` accepts `:formatter` and `:fragmenter` parameters (Jeremy McNevin)
19
+ * Default `headerBufferSize` is increased for packaged Solr make sure the limit is not reached during large queries (gjb83)
20
+ * Packaged Solr respects the `data_path` configuration setting from `sunspot.yml` (djmaze)
21
+ * Packaged Solr correctly uses the `pid_dir` configuration option from `sunspot.yml` (Russen Guggemos)
22
+ * Specs run correctly in 1.9.2 (Larry Sprock)
23
+ * Documentation improvements (Thibaut Barrère, gjb83, Breno Santos Salgado)
24
+ * Adds :offset option to paginate method (Benjamin Fleischer)
25
+ * Requires rsolr 1.0.6, which fixes issues with Unicode characters
26
+ returned by Solr
27
+
28
+ == 1.2.1 2010-12-28
29
+ * Decreased default reindexing batch size from 500 to 50
30
+
1
31
  == 1.2.0 2010-12-28
2
32
  * Replace solr-spatial-light with client-side geohash-based spatial search
3
33
  * Override Solr field naming conventions using :as option
data/Rakefile CHANGED
@@ -1,17 +1,13 @@
1
- ENV['RUBYOPT'] = '-W1'
2
-
3
1
  # encoding: UTF-8
4
- require 'bundler'
5
- Bundler::GemHelper.install_tasks
6
2
 
7
- require 'spec/rake/spectask'
3
+ require 'rspec/core/rake_task'
8
4
 
9
5
  Dir['tasks/**/*.rake'].each { |t| load t }
10
6
 
11
7
  desc "Run all examples"
12
- Spec::Rake::SpecTask.new(:spec) do |t|
13
- t.spec_files = Dir.glob('spec/**/*_spec.rb')
14
- t.spec_opts << '--format specdoc'
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = '--format documentation'
10
+ t.ruby_opts = "-W1"
15
11
  end
16
12
 
17
- task :default => 'spec'
13
+ task :default => :spec
@@ -14,7 +14,7 @@ require File.join(File.dirname(__FILE__), 'light_config')
14
14
 
15
15
  %w(util adapters configuration setup composite_setup text_field_setup field
16
16
  field_factory data_extractor indexer query search session session_proxy
17
- type dsl).each do |filename|
17
+ type dsl class_set).each do |filename|
18
18
  require File.join(File.dirname(__FILE__), 'sunspot', filename)
19
19
  end
20
20
 
@@ -41,9 +41,12 @@ module Sunspot
41
41
  IllegalSearchError = Class.new(StandardError)
42
42
  NotImplementedError = Class.new(StandardError)
43
43
 
44
- autoload :Server, File.join(File.dirname(__FILE__), 'sunspot', 'server')
45
44
  autoload :Installer, File.join(File.dirname(__FILE__), 'sunspot', 'installer')
46
45
 
46
+ # Array to track classes that have been set up for searching.
47
+ # Used by, e.g., Sunspot::Rails for reindexing all searchable classes.
48
+ @searchable = ClassSet.new
49
+
47
50
  class <<self
48
51
  #
49
52
  # Clients can inject a session proxy, allowing them to implement custom
@@ -53,6 +56,11 @@ module Sunspot
53
56
  #
54
57
  attr_writer :session
55
58
 
59
+ #
60
+ # Access the list of classes set up to be searched.
61
+ #
62
+ attr_reader :searchable
63
+
56
64
  # Configures indexing and search for a given class.
57
65
  #
58
66
  # ==== Parameters
@@ -154,6 +162,7 @@ module Sunspot
154
162
  # the dynamic name, which is the part that is specified at indexing time.
155
163
  #
156
164
  def setup(clazz, &block)
165
+ Sunspot.searchable << clazz
157
166
  Setup.setup(clazz, &block)
158
167
  end
159
168
 
@@ -329,7 +338,8 @@ module Sunspot
329
338
  # end
330
339
  #
331
340
  # See Sunspot::DSL::Search, Sunspot::DSL::Scope, Sunspot::DSL::FieldQuery
332
- # and Sunspot::DSL::Query for the full API presented inside the block.
341
+ # and Sunspot::DSL::StandardQuery for the full API presented inside the
342
+ # block.
333
343
  #
334
344
  def search(*types, &block)
335
345
  session.search(*types, &block)
@@ -0,0 +1,62 @@
1
+ module Sunspot
2
+ #
3
+ # Keeps a stack of batches and helps out when Indexer is asked to batch documents.
4
+ #
5
+ # If the client does something like
6
+ #
7
+ # Sunspot.batch do
8
+ # some_code_here
9
+ # which_triggers_some_other_code
10
+ # which_again_calls
11
+ # Sunspot.batch { ... }
12
+ # end
13
+ #
14
+ # it is the Batcher's job to keep track of these nestings. The inner will
15
+ # be sent of to be indexed first.
16
+ #
17
+ class Batcher
18
+ include Enumerable
19
+
20
+ # Raised if you ask to end current, but no current exists
21
+ class NoCurrentBatchError < StandardError; end
22
+
23
+ def initialize
24
+ @stack = []
25
+ end
26
+
27
+ def current
28
+ @stack.last or start_new
29
+ end
30
+
31
+ def start_new
32
+ (@stack << []).last
33
+ end
34
+
35
+ def end_current
36
+ fail NoCurrentBatchError if @stack.empty?
37
+
38
+ @stack.pop
39
+ end
40
+
41
+ def depth
42
+ @stack.length
43
+ end
44
+
45
+ def batching?
46
+ depth > 0
47
+ end
48
+
49
+ def each(&block)
50
+ current.each(&block)
51
+ end
52
+
53
+ def push(value)
54
+ current << value
55
+ end
56
+ alias << push
57
+
58
+ def concat(values)
59
+ current.concat values
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,23 @@
1
+ module Sunspot
2
+ class ClassSet
3
+ include Enumerable
4
+
5
+ def initialize
6
+ @name_to_klass = {}
7
+ end
8
+
9
+ def <<(klass)
10
+ @name_to_klass[klass.name.to_sym] = klass
11
+ self
12
+ end
13
+ alias_method :add, :<<
14
+
15
+ def each(&block)
16
+ @name_to_klass.values.each(&block)
17
+ end
18
+
19
+ def empty?
20
+ @name_to_klass.empty?
21
+ end
22
+ end
23
+ end
@@ -8,6 +8,8 @@ module Sunspot
8
8
  # Sunspot.config.pagination.default_per_page::
9
9
  # Solr always paginates its results. This sets Sunspot's default result
10
10
  # count per page if it is not explicitly specified in the query.
11
+ # Sunspot.config.indexing.default_batch_size::
12
+ # This sets the batch size for indexing, default is 50
11
13
  #
12
14
  module Configuration
13
15
  class <<self
@@ -21,6 +23,8 @@ module Sunspot
21
23
  LightConfig.build do
22
24
  solr do
23
25
  url 'http://127.0.0.1:8983/solr'
26
+ read_timeout nil
27
+ open_timeout nil
24
28
  end
25
29
  master_solr do
26
30
  url nil
@@ -28,6 +32,9 @@ module Sunspot
28
32
  pagination do
29
33
  default_per_page 30
30
34
  end
35
+ indexing do
36
+ default_batch_size 50
37
+ end
31
38
  end
32
39
  end
33
40
 
@@ -1,5 +1,5 @@
1
1
  %w(fields scope paginatable adjustable field_query standard_query query_facet
2
2
  functional fulltext restriction restriction_with_near search
3
- more_like_this_query function).each do |file|
3
+ more_like_this_query function field_group).each do |file|
4
4
  require File.join(File.dirname(__FILE__), 'dsl', file)
5
5
  end
@@ -0,0 +1,57 @@
1
+ module Sunspot
2
+ module DSL
3
+ class FieldGroup
4
+ def initialize(query, setup, group)
5
+ @query, @setup, @group = query, setup, group
6
+ end
7
+
8
+ #
9
+ # Sets the number of results (documents) to return for each group.
10
+ # Defaults to 1.
11
+ #
12
+ def limit(num)
13
+ @group.limit = num
14
+ end
15
+
16
+ #
17
+ # If set, facet counts are based on the most relevant document of
18
+ # each group matching the query.
19
+ #
20
+ # Supported in Solr 3.4 and above.
21
+ #
22
+ # ==== Example
23
+ #
24
+ # Sunspot.search(Post) do
25
+ # group :title do
26
+ # truncate
27
+ # end
28
+ #
29
+ # facet :title, :extra => :any
30
+ # end
31
+ #
32
+ def truncate
33
+ @group.truncate = true
34
+ end
35
+
36
+ # Specify the order that results should be returned in. This method can
37
+ # be called multiple times; precedence will be in the order given.
38
+ #
39
+ # ==== Parameters
40
+ #
41
+ # field_name<Symbol>:: the field to use for ordering
42
+ # direction<Symbol>:: :asc or :desc (default :asc)
43
+ #
44
+ def order_by(field_name, direction = nil)
45
+ sort =
46
+ if special = Sunspot::Query::Sort.special(field_name)
47
+ special.new(direction)
48
+ else
49
+ Sunspot::Query::Sort::FieldSort.new(
50
+ @setup.field(field_name), direction
51
+ )
52
+ end
53
+ @group.add_sort(sort)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -31,6 +31,27 @@ module Sunspot
31
31
  @query.add_sort(sort)
32
32
  end
33
33
 
34
+ #
35
+ # Specify that the results should be ordered based on their
36
+ # distance from a given point.
37
+ #
38
+ # ==== Parameters
39
+ #
40
+ # field_name<Symbol>::
41
+ # the field that stores the location (declared as `latlon`)
42
+ # lat<Numeric>::
43
+ # the reference latitude
44
+ # lon<Numeric>::
45
+ # the reference longitude
46
+ # direction<Symbol>::
47
+ # :asc or :desc (default :asc)
48
+ #
49
+ def order_by_geodist(field_name, lat, lon, direction = nil)
50
+ @query.add_sort(
51
+ Sunspot::Query::Sort::GeodistSort.new(@setup.field(field_name), lat, lon, direction)
52
+ )
53
+ end
54
+
34
55
  #
35
56
  # DEPRECATED Use <code>order_by(:random)</code>
36
57
  #
@@ -38,6 +59,33 @@ module Sunspot
38
59
  order_by(:random)
39
60
  end
40
61
 
62
+ # Specify a field for result grouping. Grouping groups documents
63
+ # with a common field value, return only the top document per
64
+ # group.
65
+ #
66
+ # More information in the Solr documentation:
67
+ # <http://wiki.apache.org/solr/FieldCollapsing>
68
+ #
69
+ # ==== Parameters
70
+ #
71
+ # field_name<Symbol>:: the field to use for grouping
72
+ def group(*field_names, &block)
73
+ options = Sunspot::Util.extract_options_from(field_names)
74
+
75
+ field_names.each do |field_name|
76
+ field = @setup.field(field_name)
77
+ group = @query.add_group(Sunspot::Query::FieldGroup.new(field))
78
+ @search.add_field_group(field)
79
+
80
+ if block
81
+ Sunspot::Util.instance_eval_or_call(
82
+ FieldGroup.new(@query, @setup, group),
83
+ &block
84
+ )
85
+ end
86
+ end
87
+ end
88
+
41
89
  #
42
90
  # Request a facet on the search query. A facet is a feature of Solr that
43
91
  # determines the number of documents that match the existing search *and*
@@ -5,7 +5,20 @@ module Sunspot
5
5
  @functional = functional
6
6
  end
7
7
 
8
+ # Special case to handle <http://wiki.apache.org/solr/FunctionQuery#sub>
9
+ # because `Kernel#sub` exists so `method_missing` will not be called
10
+ # for this function.
11
+ def sub(*args) #:nodoc:
12
+ create_function_query(:sub, *args)
13
+ end
14
+
8
15
  def method_missing(method, *args, &block)
16
+ create_function_query(method, *args)
17
+ end
18
+
19
+ private
20
+
21
+ def create_function_query(method, *args)
9
22
  function_args = args.map { |arg| @functional.create_function_query(arg) }
10
23
  Sunspot::Query::FunctionalFunctionQuery.new(method, function_args)
11
24
  end
@@ -17,11 +17,15 @@ module Sunspot
17
17
  # How many results to return per page. The default is the value in
18
18
  # +Sunspot.config.pagination.default_per_page+
19
19
  #
20
+ # :offset<Integer,String>::
21
+ # Applies a shift to paginated records. The default is 0.
22
+ #
20
23
  def paginate(options = {})
21
24
  page = options.delete(:page)
22
25
  per_page = options.delete(:per_page)
26
+ offset = options.delete(:offset)
23
27
  raise ArgumentError, "unknown argument #{options.keys.first.inspect} passed to paginate" unless options.empty?
24
- @query.paginate(page, per_page)
28
+ @query.paginate(page, per_page, offset)
25
29
  end
26
30
  end
27
31
  end
@@ -116,6 +116,45 @@ module Sunspot
116
116
  def near(lat, lng, options = {})
117
117
  @query.fulltext.add_location(@field, lat, lng, options)
118
118
  end
119
+
120
+ #
121
+ # Performs a query that is filtered by a radius around a given
122
+ # latitude and longitude.
123
+ #
124
+ # ==== Parameters
125
+ #
126
+ # :lat<Numeric>::
127
+ # Latitude (in degrees)
128
+ # :lon<Numeric>::
129
+ # Longitude (in degrees)
130
+ # :radius<Numeric>::
131
+ # Radius (in kilometers)
132
+ #
133
+ # ==== Options
134
+ #
135
+ # <dt><code>:bbox</code></dt>
136
+ # <dd>If `true`, performs the search using `bbox`. `bbox` is
137
+ # more performant, but also more inexact (guaranteed to encompass
138
+ # all of the points of interest, but may also include other points
139
+ # that are slightly outside of the required distance).</dd>
140
+ #
141
+ def in_radius(lat, lon, radius, options = {})
142
+ @query.add_geo(Sunspot::Query::Geofilt.new(@field, lat, lon, radius, options))
143
+ end
144
+
145
+ #
146
+ # Performs a query that is filtered by a bounding box
147
+ #
148
+ # ==== Parameters
149
+ #
150
+ # :first_corner<Array>::
151
+ # First corner (expressed as an array `[latitude, longitude]`)
152
+ # :second_corner<Array>::
153
+ # Second corner (expressed as an array `[latitude, longitude]`)
154
+ #
155
+ def in_bounding_box(first_corner, second_corner)
156
+ @query.add_geo(Sunspot::Query::Bbox.new(@field, first_corner, second_corner))
157
+ end
119
158
  end
120
159
  end
121
160
  end