sunspot 0.10.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/History.txt +30 -0
  2. data/README.rdoc +59 -29
  3. data/Rakefile +2 -0
  4. data/TODO +9 -19
  5. data/VERSION.yml +2 -3
  6. data/bin/sunspot-installer +19 -0
  7. data/bin/sunspot-solr +28 -53
  8. data/installer/config/schema.yml +71 -0
  9. data/lib/sunspot/configuration.rb +0 -10
  10. data/lib/sunspot/dsl/field_query.rb +123 -7
  11. data/lib/sunspot/dsl/fields.rb +17 -4
  12. data/lib/sunspot/dsl/query.rb +11 -3
  13. data/lib/sunspot/dsl/scope.rb +6 -2
  14. data/lib/sunspot/field.rb +4 -7
  15. data/lib/sunspot/field_factory.rb +8 -5
  16. data/lib/sunspot/indexer.rb +22 -20
  17. data/lib/sunspot/installer/library_installer.rb +45 -0
  18. data/lib/sunspot/installer/schema_builder.rb +219 -0
  19. data/lib/sunspot/installer/solrconfig_updater.rb +90 -0
  20. data/lib/sunspot/installer/task_helper.rb +18 -0
  21. data/lib/sunspot/installer.rb +31 -0
  22. data/lib/sunspot/query/abstract_field_facet.rb +5 -1
  23. data/lib/sunspot/query/connective.rb +3 -1
  24. data/lib/sunspot/query/field_facet.rb +33 -1
  25. data/lib/sunspot/query/filter.rb +38 -0
  26. data/lib/sunspot/query/local.rb +10 -11
  27. data/lib/sunspot/query/query.rb +5 -12
  28. data/lib/sunspot/query/restriction.rb +2 -1
  29. data/lib/sunspot/query/scope.rb +1 -1
  30. data/lib/sunspot/query.rb +3 -3
  31. data/lib/sunspot/schema.rb +5 -1
  32. data/lib/sunspot/search/field_facet.rb +59 -15
  33. data/lib/sunspot/search/hit.rb +21 -10
  34. data/lib/sunspot/search/query_facet.rb +2 -2
  35. data/lib/sunspot/search.rb +86 -33
  36. data/lib/sunspot/server.rb +148 -0
  37. data/lib/sunspot/session.rb +39 -51
  38. data/lib/sunspot/session_proxy/abstract_session_proxy.rb +29 -0
  39. data/lib/sunspot/session_proxy/class_sharding_session_proxy.rb +66 -0
  40. data/lib/sunspot/session_proxy/id_sharding_session_proxy.rb +89 -0
  41. data/lib/sunspot/session_proxy/master_slave_session_proxy.rb +43 -0
  42. data/lib/sunspot/session_proxy/sharding_session_proxy.rb +206 -0
  43. data/lib/sunspot/session_proxy/thread_local_session_proxy.rb +30 -0
  44. data/lib/sunspot/session_proxy.rb +71 -0
  45. data/lib/sunspot/setup.rb +24 -10
  46. data/lib/sunspot/type.rb +163 -101
  47. data/lib/sunspot/util.rb +44 -2
  48. data/lib/sunspot/version.rb +3 -0
  49. data/lib/sunspot.rb +50 -17
  50. data/solr/etc/jetty.xml +4 -2
  51. data/solr/solr/conf/admin-extra.html +31 -0
  52. data/solr/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  53. data/solr/solr/conf/schema.xml +212 -50
  54. data/solr/solr/conf/scripts.conf +24 -0
  55. data/solr/solr/conf/solrconfig.xml +473 -266
  56. data/solr/solr/conf/spellings.txt +2 -0
  57. data/solr/solr/conf/stopwords.txt +1 -0
  58. data/solr/solr/lib/lucene-spatial-2.9.1.jar +0 -0
  59. data/solr/solr/lib/solr-spatial-light-0.0.3.jar +0 -0
  60. data/solr/webapps/solr.war +0 -0
  61. data/spec/api/binding_spec.rb +38 -0
  62. data/spec/api/indexer/attributes_spec.rb +37 -4
  63. data/spec/api/indexer/dynamic_fields_spec.rb +10 -1
  64. data/spec/api/indexer/removal_spec.rb +8 -1
  65. data/spec/api/indexer_spec.rb +10 -0
  66. data/spec/api/query/dsl_spec.rb +6 -0
  67. data/spec/api/query/dynamic_fields_spec.rb +9 -9
  68. data/spec/api/query/facet_local_params_spec.rb +103 -0
  69. data/spec/api/query/local_spec.rb +13 -37
  70. data/spec/api/query/ordering_pagination_spec.rb +0 -6
  71. data/spec/api/search/dynamic_fields_spec.rb +3 -3
  72. data/spec/api/search/faceting_spec.rb +113 -10
  73. data/spec/api/search/hits_spec.rb +49 -0
  74. data/spec/api/search/results_spec.rb +8 -1
  75. data/spec/api/server_spec.rb +85 -0
  76. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +85 -0
  77. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +30 -0
  78. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +41 -0
  79. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +77 -0
  80. data/spec/api/session_proxy/spec_helper.rb +9 -0
  81. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +33 -0
  82. data/spec/ext.rb +11 -0
  83. data/spec/helpers/search_helper.rb +6 -8
  84. data/spec/integration/faceting_spec.rb +46 -4
  85. data/spec/integration/indexing_spec.rb +27 -1
  86. data/spec/integration/local_search_spec.rb +25 -7
  87. data/spec/integration/scoped_search_spec.rb +48 -36
  88. data/spec/mocks/comment.rb +7 -5
  89. data/spec/mocks/connection.rb +14 -13
  90. data/spec/mocks/mock_class_sharding_session_proxy.rb +24 -0
  91. data/spec/mocks/mock_record.rb +7 -3
  92. data/spec/mocks/mock_sharding_session_proxy.rb +15 -0
  93. data/spec/mocks/photo.rb +4 -3
  94. data/spec/mocks/post.rb +1 -1
  95. data/spec/spec_helper.rb +2 -1
  96. data/tasks/gemspec.rake +26 -36
  97. data/tasks/rdoc.rake +9 -4
  98. metadata +203 -203
  99. data/bin/sunspot-configure-solr +0 -40
  100. data/solr/solr/lib/geoapi-nogenerics-2.1-M2.jar +0 -0
  101. data/solr/solr/lib/gt2-referencing-2.3.1.jar +0 -0
  102. data/solr/solr/lib/jsr108-0.01.jar +0 -0
  103. data/solr/solr/lib/locallucene.jar +0 -0
  104. data/solr/solr/lib/localsolr.jar +0 -0
  105. data/templates/schema.xml.erb +0 -36
@@ -0,0 +1,2 @@
1
+ pizza
2
+ history
@@ -20,6 +20,7 @@ stopworda
20
20
  stopwordb
21
21
 
22
22
  #Standard english stop words taken from Lucene's StopAnalyzer
23
+ a
23
24
  an
24
25
  and
25
26
  are
Binary file
@@ -0,0 +1,38 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe "DSL bindings" do
4
+ it 'should give access to calling context\'s methods in search DSL' do
5
+ value = nil
6
+ session.search(Post) do
7
+ value = test_method
8
+ end
9
+ value.should == 'value'
10
+ end
11
+
12
+ it 'should give access to calling context\'s methods in nested DSL block' do
13
+ value = nil
14
+ session.search(Post) do
15
+ any_of do
16
+ value = test_method
17
+ end
18
+ end
19
+ value.should == 'value'
20
+ end
21
+
22
+ it 'should give access to calling context\'s methods in double-nested DSL block' do
23
+ value = nil
24
+ session.search(Post) do
25
+ any_of do
26
+ all_of do
27
+ value = test_method
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def test_method
36
+ 'value'
37
+ end
38
+ end
@@ -11,11 +11,36 @@ describe 'indexing attribute fields', :type => :indexer do
11
11
  connection.should have_add_with(:blog_id_i => '4')
12
12
  end
13
13
 
14
+ it 'should correctly index a long attribute field' do
15
+ session.index(Namespaced::Comment.new(:hash => 2**30))
16
+ connection.should have_add_with(:hash_l => '1073741824')
17
+ end
18
+
14
19
  it 'should correctly index a float attribute field' do
15
20
  session.index(post(:ratings_average => 2.23))
16
21
  connection.should have_add_with(:average_rating_f => '2.23')
17
22
  end
18
23
 
24
+ it 'should correctly index a double attribute field' do
25
+ session.index(Namespaced::Comment.new(:average_rating => 2.23))
26
+ connection.should have_add_with(:average_rating_e => '2.23')
27
+ end
28
+
29
+ it 'should correctly index a trie integer attribute field' do
30
+ session.index(Photo.new(:size => 104856))
31
+ connection.should have_add_with(:size_it => '104856')
32
+ end
33
+
34
+ it 'should correctly index a trie float attribute field' do
35
+ session.index(Photo.new(:average_rating => 2.23))
36
+ connection.should have_add_with(:average_rating_ft => '2.23')
37
+ end
38
+
39
+ it 'should correctly index a trie time attribute field' do
40
+ session.index(Photo.new(:created_at => Time.parse('2009-12-16 15:00:00 -0400')))
41
+ connection.should have_add_with(:created_at_dt => '2009-12-16T19:00:00Z')
42
+ end
43
+
19
44
  it 'should allow indexing by a multiple-value field' do
20
45
  session.index(post(:category_ids => [3, 14]))
21
46
  connection.should have_add_with(:category_ids_im => ['3', '14'])
@@ -33,6 +58,13 @@ describe 'indexing attribute fields', :type => :indexer do
33
58
  connection.should have_add_with(:published_at_d => '1983-07-08T09:00:00Z')
34
59
  end
35
60
 
61
+ it 'should correctly index a time field that\'s after 32-bit Y2K' do
62
+ session.index(
63
+ post(:published_at => DateTime.parse('2050-07-08 05:00:00 -0400'))
64
+ )
65
+ connection.should have_add_with(:published_at_d => '2050-07-08T09:00:00Z')
66
+ end
67
+
36
68
  it 'should correctly index a date field' do
37
69
  session.index(post(:expire_date => Date.new(2009, 07, 13)))
38
70
  connection.should have_add_with(:expire_date_d => '2009-07-13T00:00:00Z')
@@ -55,25 +87,26 @@ describe 'indexing attribute fields', :type => :indexer do
55
87
 
56
88
  it 'should index latitude and longitude as a pair' do
57
89
  session.index(post(:coordinates => [40.7, -73.5]))
58
- connection.should have_add_with(:lat => 40.7, :long => -73.5)
90
+ connection.should have_add_with(:lat => 40.7, :lng => -73.5)
59
91
  end
60
92
 
61
93
  [
62
94
  [:lat, :lng],
63
95
  [:lat, :lon],
64
- [:lat, :long]
96
+ [:lat, :long],
97
+ [:latitude, :longitude]
65
98
  ].each do |lat_attr, lng_attr|
66
99
  it "should index latitude and longitude from #{lat_attr.inspect}, #{lng_attr.inspect}" do
67
100
  session.index(post(
68
101
  :coordinates => OpenStruct.new(lat_attr => 40.7, lng_attr => -73.5)
69
102
  ))
70
- connection.should have_add_with(:lat => 40.7, :long => -73.5)
103
+ connection.should have_add_with(:lat => 40.7, :lng => -73.5)
71
104
  end
72
105
  end
73
106
 
74
107
  it 'should index latitude and longitude from a block' do
75
108
  session.index(Photo.new(:lat => 30, :lng => -60))
76
- connection.should have_add_with(:lat => 30, :long => -60)
109
+ connection.should have_add_with(:lat => 30.0, :lng => -60.0)
77
110
  end
78
111
 
79
112
  it 'should correctly index an attribute field with block access' do
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
3
3
  describe 'indexing dynamic fields' do
4
4
  it 'indexes string data' do
5
5
  session.index(post(:custom_string => { :test => 'string' }))
6
- connection.should have_add_with(:"custom_string:test_s" => 'string')
6
+ connection.should have_add_with(:"custom_string:test_ss" => 'string')
7
7
  end
8
8
 
9
9
  it 'indexes integer data with virtual accessor' do
@@ -30,4 +30,13 @@ describe 'indexing dynamic fields' do
30
30
  session.index(post(:custom_fl => { :test => [1.0, 2.1, 3.2] }))
31
31
  connection.should have_add_with(:"custom_float:test_fm" => %w(1.0 2.1 3.2))
32
32
  end
33
+
34
+ it 'should throw a NoMethodError if dynamic text field defined' do
35
+ lambda do
36
+ Sunspot.setup(Post) do
37
+ dynamic_text :custom_text
38
+ end
39
+ end.should raise_error(NoMethodError)
40
+ end
33
41
  end
42
+
@@ -12,7 +12,7 @@ describe 'document removal', :type => :indexer do
12
12
  end
13
13
 
14
14
  it 'removes an object by type and id and immediately commits' do
15
- connection.should_receive(:delete_by_id).with('Post 1').ordered
15
+ connection.should_receive(:delete_by_id).with(['Post 1']).ordered
16
16
  connection.should_receive(:commit).ordered
17
17
  session.remove_by_id!(Post, 1)
18
18
  end
@@ -43,4 +43,11 @@ describe 'document removal', :type => :indexer do
43
43
  connection.should_receive(:delete_by_query).with('type:Namespaced\:\:Comment')
44
44
  session.remove_all(Namespaced::Comment)
45
45
  end
46
+
47
+ it 'should remove by query' do
48
+ session.remove(Post) do
49
+ with(:title, 'monkeys')
50
+ end
51
+ connection.should have_delete_by_query("(type:Post AND title_ss:monkeys)")
52
+ end
46
53
  end
@@ -1,4 +1,14 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe 'indexer', :type => :indexer do
4
+ it 'should completely wipe setup if class redefined (reloaded)' do
5
+ Object::ReloadableClass = Class.new(MockRecord)
6
+ Sunspot.setup(ReloadableClass) { string(:title) }
7
+ Object.class_eval { remove_const(:ReloadableClass) }
8
+ Object::ReloadableClass = Class.new(MockRecord)
9
+ Sunspot.setup(ReloadableClass) {}
10
+ lambda do
11
+ Sunspot.search(ReloadableClass) { with(:title, 'title') }
12
+ end.should raise_error(Sunspot::UnrecognizedFieldError)
13
+ end
4
14
  end
@@ -8,5 +8,11 @@ describe 'query DSL', :type => :query do
8
8
  end
9
9
  connection.should have_last_search_including(:fq, 'blog_id_i:1')
10
10
  end
11
+
12
+ it 'should accept a block in the #new_search method' do
13
+ search = session.new_search(Post) { with(:blog_id, 1) }
14
+ search.execute
15
+ connection.should have_last_search_including(:fq, 'blog_id_i:1')
16
+ end
11
17
  end
12
18
 
@@ -7,7 +7,7 @@ describe 'dynamic field query', :type => :query do
7
7
  with :test, 'string'
8
8
  end
9
9
  end
10
- connection.should have_last_search_including(:fq, 'custom_string\:test_s:string')
10
+ connection.should have_last_search_including(:fq, 'custom_string\:test_ss:string')
11
11
  end
12
12
 
13
13
  it 'restricts by dynamic integer field with less than restriction' do
@@ -53,7 +53,7 @@ describe 'dynamic field query', :type => :query do
53
53
  without :test, 'foo'
54
54
  end
55
55
  end
56
- connection.should have_last_search_including(:fq, '-custom_string\:test_s:foo')
56
+ connection.should have_last_search_including(:fq, '-custom_string\:test_ss:foo')
57
57
  end
58
58
 
59
59
  it 'scopes by a dynamic field inside a disjunction' do
@@ -66,7 +66,7 @@ describe 'dynamic field query', :type => :query do
66
66
  end
67
67
  end
68
68
  connection.should have_last_search_including(
69
- :fq, '(custom_string\:test_s:foo OR title_ss:bar)'
69
+ :fq, '(custom_string\:test_ss:foo OR title_ss:bar)'
70
70
  )
71
71
  end
72
72
 
@@ -101,7 +101,7 @@ describe 'dynamic field query', :type => :query do
101
101
  lambda do
102
102
  session.search Post do
103
103
  dynamic :custom_string do
104
- paginate 3, 10
104
+ paginate :page => 3, :per_page => 10
105
105
  end
106
106
  end
107
107
  end.should raise_error(NoMethodError)
@@ -118,7 +118,7 @@ describe 'dynamic field query', :type => :query do
118
118
  end
119
119
  end
120
120
  connection.should have_last_search_with(
121
- :"facet.query" => 'custom_string\:test_s:foo'
121
+ :"facet.query" => 'custom_string\:test_ss:foo'
122
122
  )
123
123
  end
124
124
 
@@ -134,16 +134,16 @@ describe 'dynamic field query', :type => :query do
134
134
  end
135
135
  connection.should have_last_search_including(
136
136
  :"facet.query",
137
- 'custom_string\:test_s:foo'
137
+ 'custom_string\:test_ss:foo'
138
138
  )
139
139
  end
140
140
 
141
141
  it 'allows scoping on dynamic fields common to all types' do
142
142
  session.search Post, Namespaced::Comment do
143
- dynamic :custom_string do
144
- with(:test, 'test')
143
+ dynamic :custom_float do
144
+ with(:test, 1.23)
145
145
  end
146
146
  end
147
- connection.should have_last_search_including(:fq, 'custom_string\\:test_s:test')
147
+ connection.should have_last_search_including(:fq, 'custom_float\\:test_fm:1\\.23')
148
148
  end
149
149
  end
@@ -0,0 +1,103 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe 'facet local params' do
4
+ it 'tags and excludes a scope filter in a field facet' do
5
+ session.search(Post) do
6
+ blog_filter = with(:blog_id, 1)
7
+ facet(:blog_id, :exclude => blog_filter)
8
+ end
9
+ filter_tag = get_filter_tag('blog_id_i:1')
10
+ connection.should have_last_search_with(
11
+ :"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
12
+ )
13
+ end
14
+
15
+ it 'tags and excludes a disjunction filter in a field facet' do
16
+ session.search(Post) do
17
+ blog_filter = any_of do
18
+ with(:blog_id, 1)
19
+ with(:blog_id, 2)
20
+ end
21
+ facet(:blog_id, :exclude => blog_filter)
22
+ end
23
+ filter_tag = get_filter_tag('(blog_id_i:1 OR blog_id_i:2)')
24
+ connection.should have_last_search_with(
25
+ :"facet.field" => %W({!ex=#{filter_tag}}blog_id_i)
26
+ )
27
+ end
28
+
29
+ it 'tags and excludes multiple filters in a field facet' do
30
+ session.search(Post) do
31
+ blog_filter = with(:blog_id, 1)
32
+ category_filter = with(:category_ids, 2)
33
+ facet(:blog_id, :exclude => [blog_filter, category_filter])
34
+ end
35
+ filter_tags = %w(blog_id_i:1 category_ids_im:2).map do |phrase|
36
+ get_filter_tag(phrase)
37
+ end.join(',')
38
+ connection.should have_last_search_with(
39
+ :"facet.field" => %W({!ex=#{filter_tags}}blog_id_i)
40
+ )
41
+ end
42
+
43
+ it 'does not tag a filter if it is not excluded' do
44
+ session.search(Post) do
45
+ with(:blog_id, 1)
46
+ end
47
+ connection.should have_last_search_including(:fq, "blog_id_i:1")
48
+ end
49
+
50
+ it 'names a field facet' do
51
+ session.search(Post) do
52
+ facet(:blog_id, :name => :blog)
53
+ end
54
+ connection.should have_last_search_including(:"facet.field", "{!key=blog}blog_id_i")
55
+ end
56
+
57
+ it 'uses the custom field facet name in facet option parameters' do
58
+ session.search(Post) do
59
+ facet(:blog_id, :name => :blog, :sort => :count)
60
+ end
61
+ connection.should have_last_search_with(:"f.blog.facet.sort" => 'true')
62
+ end
63
+
64
+ it 'raises an ArgumentError if exclusion attempted on a query facet' do
65
+ lambda do
66
+ session.search(Post) do
67
+ blog_filter = with(:blog_id, 1)
68
+ facet(:bad, :exclude => blog_filter) do
69
+ row(:bogus) { with(:blog_id, 1) }
70
+ end
71
+ end
72
+ end.should raise_error(ArgumentError)
73
+ end
74
+
75
+ it 'raises an ArgumentError if exclusion attempted on a restricted field facet' do
76
+ lambda do
77
+ session.search(Post) do
78
+ blog_filter = with(:blog_id, 1)
79
+ facet(:blog_id, :only => 1, :exclude => blog_filter)
80
+ end
81
+ end.should raise_error(ArgumentError)
82
+ end
83
+
84
+ it 'raises an ArgumentError if exclusion attempted on a facet with :extra' do
85
+ lambda do
86
+ session.search(Post) do
87
+ blog_filter = with(:blog_id, 1)
88
+ facet(:blog_id, :extra => :all, :exclude => blog_filter)
89
+ end
90
+ end.should raise_error(ArgumentError)
91
+ end
92
+
93
+ private
94
+
95
+ def get_filter_tag(boolean_query)
96
+ connection.searches.last[:fq].each do |fq|
97
+ if match = fq.match(/^\{!tag=(.+)\}#{Regexp.escape(boolean_query)}$/)
98
+ return match[1]
99
+ end
100
+ end
101
+ nil
102
+ end
103
+ end
@@ -1,62 +1,38 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe 'local query' do
4
- it 'sets query type to geo when geo search performed' do
4
+ it 'sends lat and lng, and distance when geo search is performed' do
5
5
  session.search Post do
6
- near [40.7, -73.5], 5
6
+ near [40.7, -73.5], :distance => 5
7
7
  end
8
- connection.should have_last_search_with(:qt => 'geo')
8
+ connection.should have_last_search_with(:spatial => "{!radius=5}40.7,-73.5")
9
9
  end
10
10
 
11
- it 'sets lat and lng when geo search is performed' do
11
+ it 'sets lat, lng, and sort flag when sorted geo search is performed' do
12
12
  session.search Post do
13
- near [40.7, -73.5], 5
13
+ near [40.7, -73.5], :sort => true
14
14
  end
15
- connection.should have_last_search_with(:lat => 40.7, :long => -73.5)
15
+ connection.should have_last_search_with(:spatial => "{!sort=true}40.7,-73.5")
16
16
  end
17
17
 
18
- it 'sets radius when geo search is performed' do
18
+ it 'sets radius and sort when both are specified' do
19
19
  session.search Post do
20
- near [40.7, -73.5], 5
20
+ near [40.7, -73.5], :distance => 5, :sort => true
21
21
  end
22
- connection.should have_last_search_with(:radius => 5)
23
- end
24
-
25
- it 'puts all scope parameters into :q parameter when geo search is performed' do
26
- session.search Post do
27
- with :blog_id, 1
28
- near [40.7, -73.5], 5
29
- end
30
- connection.should have_last_search_with(:q => '(type:Post AND blog_id_i:1)')
31
- end
32
-
33
- it 'raises error if keywords specified in local search' do
34
- lambda do
35
- session.search Post do
36
- keywords 'fail'
37
- near [40.7, -73.5], 5
38
- end
39
- end.should raise_error(Sunspot::IllegalSearchError)
22
+ connection.should have_last_search_with(:spatial => "{!radius=5 sort=true}40.7,-73.5")
40
23
  end
41
24
 
42
25
  [
43
26
  [:lat, :lng],
44
27
  [:lat, :lon],
45
- [:lat, :long]
28
+ [:lat, :long],
29
+ [:latitude, :longitude]
46
30
  ].each do |lat_attr, lng_attr|
47
31
  it "sets coordinates using #{lat_attr.inspect}, #{lng_attr.inspect}" do
48
32
  session.search Post do
49
- near OpenStruct.new(lat_attr => 40.7, lng_attr => -73.5), 5
33
+ near OpenStruct.new(lat_attr => 40.7, lng_attr => -73.5), :distance => 5
50
34
  end
51
- connection.should have_last_search_with(:lat => 40.7, :long => -73.5)
35
+ connection.should have_last_search_with(:spatial => "{!radius=5}40.7,-73.5")
52
36
  end
53
37
  end
54
-
55
- it 'raises ArgumentError if radius is less than 1' do
56
- lambda do
57
- session.search Post do
58
- near [40, -70], 0.5
59
- end
60
- end.should raise_error(ArgumentError)
61
- end
62
38
  end
@@ -63,12 +63,6 @@ describe 'ordering and pagination' do
63
63
  connection.should have_last_search_with(:sort => 'score desc')
64
64
  end
65
65
 
66
- it 'orders by geo distance' do
67
- session.search Post do
68
- order_by :distance, :asc
69
- end
70
- end
71
-
72
66
  it 'throws an ArgumentError if a bogus order direction is given' do
73
67
  lambda do
74
68
  session.search Post do
@@ -2,14 +2,14 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
3
  describe 'search with dynamic fields' do
4
4
  it 'returns dynamic string facet' do
5
- stub_facet(:"custom_string:test_s", 'two' => 2, 'one' => 1)
5
+ stub_facet(:"custom_string:test_ss", 'two' => 2, 'one' => 1)
6
6
  result = session.search(Post) { dynamic(:custom_string) { facet(:test) }}
7
- result.dynamic_facet(:custom_string, :test).rows.map { |row| row.value }.should == ['two', 'one']
7
+ result.facet(:custom_string, :test).rows.map { |row| row.value }.should == ['two', 'one']
8
8
  end
9
9
 
10
10
  it 'returns query facet specified in dynamic call' do
11
11
  stub_query_facet(
12
- 'custom_string\:test_s:(foo OR bar)' => 3
12
+ 'custom_string\:test_ss:(foo OR bar)' => 3
13
13
  )
14
14
  search = session.search(Post) do
15
15
  dynamic :custom_string do