sunspot 2.2.7 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -8
  6. data/gemfiles/.gitkeep +0 -0
  7. data/lib/sunspot/dsl/scope.rb +6 -1
  8. data/lib/sunspot/field.rb +11 -0
  9. data/lib/sunspot/field_factory.rb +6 -2
  10. data/lib/sunspot/query/bbox.rb +5 -1
  11. data/lib/sunspot/query/restriction.rb +11 -0
  12. data/lib/sunspot/search/hit_enumerable.rb +4 -1
  13. data/lib/sunspot/search/standard_search.rb +2 -3
  14. data/lib/sunspot/version.rb +1 -1
  15. data/spec/api/adapters_spec.rb +19 -19
  16. data/spec/api/batcher_spec.rb +15 -15
  17. data/spec/api/binding_spec.rb +3 -3
  18. data/spec/api/class_set_spec.rb +3 -3
  19. data/spec/api/hit_enumerable_spec.rb +32 -9
  20. data/spec/api/indexer/attributes_spec.rb +31 -31
  21. data/spec/api/indexer/batch_spec.rb +8 -7
  22. data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
  23. data/spec/api/indexer/fixed_fields_spec.rb +12 -12
  24. data/spec/api/indexer/fulltext_spec.rb +8 -8
  25. data/spec/api/indexer/removal_spec.rb +14 -14
  26. data/spec/api/indexer_spec.rb +2 -2
  27. data/spec/api/query/advanced_manipulation_examples.rb +3 -3
  28. data/spec/api/query/connectives_examples.rb +26 -14
  29. data/spec/api/query/dsl_spec.rb +17 -9
  30. data/spec/api/query/dynamic_fields_examples.rb +18 -18
  31. data/spec/api/query/faceting_examples.rb +62 -62
  32. data/spec/api/query/fulltext_examples.rb +56 -55
  33. data/spec/api/query/function_spec.rb +26 -26
  34. data/spec/api/query/geo_examples.rb +6 -6
  35. data/spec/api/query/group_spec.rb +6 -6
  36. data/spec/api/query/highlighting_examples.rb +26 -26
  37. data/spec/api/query/join_spec.rb +2 -2
  38. data/spec/api/query/more_like_this_spec.rb +29 -29
  39. data/spec/api/query/ordering_pagination_examples.rb +25 -25
  40. data/spec/api/query/scope_examples.rb +39 -39
  41. data/spec/api/query/spatial_examples.rb +3 -3
  42. data/spec/api/query/spellcheck_examples.rb +3 -3
  43. data/spec/api/query/standard_spec.rb +1 -1
  44. data/spec/api/query/stats_examples.rb +8 -8
  45. data/spec/api/query/text_field_scoping_examples.rb +5 -5
  46. data/spec/api/query/types_spec.rb +4 -4
  47. data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
  48. data/spec/api/search/dynamic_fields_spec.rb +4 -4
  49. data/spec/api/search/faceting_spec.rb +55 -52
  50. data/spec/api/search/highlighting_spec.rb +7 -7
  51. data/spec/api/search/hits_spec.rb +29 -29
  52. data/spec/api/search/paginated_collection_spec.rb +18 -18
  53. data/spec/api/search/results_spec.rb +13 -13
  54. data/spec/api/search/search_spec.rb +3 -3
  55. data/spec/api/search/stats_spec.rb +10 -10
  56. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
  57. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
  58. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
  59. data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
  60. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
  61. data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
  62. data/spec/api/session_proxy/spec_helper.rb +1 -1
  63. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
  64. data/spec/api/session_spec.rb +42 -42
  65. data/spec/api/sunspot_spec.rb +4 -4
  66. data/spec/integration/atomic_updates_spec.rb +25 -11
  67. data/spec/integration/dynamic_fields_spec.rb +10 -10
  68. data/spec/integration/faceting_spec.rb +39 -39
  69. data/spec/integration/field_grouping_spec.rb +16 -16
  70. data/spec/integration/field_lists_spec.rb +41 -0
  71. data/spec/integration/geospatial_spec.rb +19 -8
  72. data/spec/integration/highlighting_spec.rb +5 -5
  73. data/spec/integration/indexing_spec.rb +5 -5
  74. data/spec/integration/keyword_search_spec.rb +47 -45
  75. data/spec/integration/local_search_spec.rb +4 -4
  76. data/spec/integration/more_like_this_spec.rb +7 -7
  77. data/spec/integration/scoped_search_spec.rb +107 -107
  78. data/spec/integration/spellcheck_spec.rb +52 -7
  79. data/spec/integration/stats_spec.rb +10 -10
  80. data/spec/integration/stored_fields_spec.rb +1 -1
  81. data/spec/integration/test_pagination.rb +4 -4
  82. data/spec/integration/unicode_spec.rb +1 -1
  83. data/spec/mocks/post.rb +5 -1
  84. data/spec/spec_helper.rb +11 -6
  85. data/sunspot.gemspec +3 -1
  86. metadata +40 -7
@@ -21,7 +21,7 @@ describe 'spellcheck' do
21
21
  search = Sunspot.search(Post) do
22
22
  keywords 'Closure'
23
23
  end
24
- search.spellcheck_suggestions.should == {}
24
+ expect(search.spellcheck_suggestions).to eq({})
25
25
  end
26
26
 
27
27
  it 'returns the list of suggestions' do
@@ -29,9 +29,9 @@ describe 'spellcheck' do
29
29
  keywords 'Closure'
30
30
  spellcheck :count => 3
31
31
  end
32
- search.spellcheck_suggestions['closure']['suggestion'].should == [
32
+ expect(search.spellcheck_suggestions['closure']['suggestion']).to eq([
33
33
  {'word'=>'clojure', 'freq'=>2}, {'word'=>'conjure', 'freq'=>1}
34
- ]
34
+ ])
35
35
  end
36
36
 
37
37
  it 'returns suggestion with highest frequency' do
@@ -39,7 +39,7 @@ describe 'spellcheck' do
39
39
  keywords 'Closure'
40
40
  spellcheck :count => 3
41
41
  end
42
- search.spellcheck_suggestion_for('closure').should == 'clojure'
42
+ expect(search.spellcheck_suggestion_for('closure')).to eq('clojure')
43
43
  end
44
44
 
45
45
  it 'returns suggestion without collation when only more popular is true' do
@@ -48,7 +48,7 @@ describe 'spellcheck' do
48
48
  spellcheck :count => 3, :only_more_popular => true, :collate => false
49
49
  end
50
50
 
51
- search.spellcheck_suggestion_for('closure').should == 'clojure'
51
+ expect(search.spellcheck_suggestion_for('closure')).to eq('clojure')
52
52
  end
53
53
 
54
54
  context 'spellcheck collation' do
@@ -58,7 +58,7 @@ describe 'spellcheck' do
58
58
  keywords 'lojure developing'
59
59
  spellcheck :count => 3, :only_more_popular => true
60
60
  end
61
- search.spellcheck_collation('lojure', 'developing').should == 'clojure developing'
61
+ expect(search.spellcheck_collation('lojure', 'developing')).to eq('clojure developing')
62
62
  end
63
63
 
64
64
  it 'returns Solr collation if terms are not provided' do
@@ -67,7 +67,52 @@ describe 'spellcheck' do
67
67
  keywords 'lojure developing'
68
68
  spellcheck :count => 3, :only_more_popular => true
69
69
  end
70
- search.spellcheck_collation.should == 'clojure developer'
70
+ expect(search.spellcheck_collation).to eq('clojure developer')
71
+ end
72
+
73
+ it 'returns Solr collation if terms are not provided even for single word' do
74
+
75
+ search = Sunspot.search(Post) do
76
+ keywords 'lojure'
77
+ spellcheck :count => 3, :only_more_popular => true
78
+ end
79
+ expect(search.spellcheck_collation).to eq('clojure')
80
+ end
81
+
82
+ it 'returns Solr collation if terms are provided even for single word' do
83
+
84
+ search = Sunspot.search(Post) do
85
+ keywords 'lojure'
86
+ spellcheck :count => 3
87
+ end
88
+ expect(search.spellcheck_collation).to eq('clojure')
89
+ end
90
+
91
+ it 'returns Solr collation if terms are provided even for single word' do
92
+
93
+ search = Sunspot.search(Post) do
94
+ keywords 'lojure'
95
+ spellcheck :count => 3
96
+ end
97
+ expect(search.spellcheck_collation('lojure')).to eq('clojure')
98
+ end
99
+
100
+ it 'returns Solr collation if terms are provided even if single keyword is word' do
101
+
102
+ search = Sunspot.search(Post) do
103
+ keywords 'C++, lojure Developer'
104
+ spellcheck :count => 3
105
+ end
106
+ expect(search.spellcheck_collation).to eq('C++, clojure Developer')
107
+ end
108
+
109
+ it 'returns nil if terms are provided which varies from actual keywords' do
110
+
111
+ search = Sunspot.search(Post) do
112
+ keywords 'clojure'
113
+ spellcheck :count => 3
114
+ end
115
+ expect(search.spellcheck_collation('lojure')).to eq(nil)
71
116
  end
72
117
  end
73
118
 
@@ -10,38 +10,38 @@ describe 'search stats' do
10
10
  end
11
11
 
12
12
  it 'returns minimum stats' do
13
- Sunspot.search(Post) do
13
+ expect(Sunspot.search(Post) do
14
14
  stats :average_rating
15
- end.stats(:average_rating).min.should == 3.0
15
+ end.stats(:average_rating).min).to eq(3.0)
16
16
  end
17
17
 
18
18
  it 'returns maximum stats' do
19
- Sunspot.search(Post) do
19
+ expect(Sunspot.search(Post) do
20
20
  stats :average_rating
21
- end.stats(:average_rating).max.should == 4.0
21
+ end.stats(:average_rating).max).to eq(4.0)
22
22
  end
23
23
 
24
24
  it 'returns count stats' do
25
- Sunspot.search(Post) do
25
+ expect(Sunspot.search(Post) do
26
26
  stats :average_rating
27
- end.stats(:average_rating).count.should == 3
27
+ end.stats(:average_rating).count).to eq(3)
28
28
  end
29
29
 
30
30
  describe 'facets' do
31
31
  it 'returns minimum on facet row with two blog ids' do
32
- Sunspot.search(Post) do
32
+ expect(Sunspot.search(Post) do
33
33
  stats :average_rating do
34
34
  facet :blog_id
35
35
  end
36
- end.stats(:average_rating).facet(:blog_id).rows[1].min.should == 3.0
36
+ end.stats(:average_rating).facet(:blog_id).rows[1].min).to eq(3.0)
37
37
  end
38
38
 
39
39
  it 'returns maximum on facet row with two blog ids' do
40
- Sunspot.search(Post) do
40
+ expect(Sunspot.search(Post) do
41
41
  stats :average_rating do
42
42
  facet :blog_id
43
43
  end
44
- end.stats(:average_rating).facet(:blog_id).rows[1].max.should == 4.0
44
+ end.stats(:average_rating).facet(:blog_id).rows[1].max).to eq(4.0)
45
45
  end
46
46
  end
47
47
  end
@@ -7,6 +7,6 @@ describe 'stored fields' do
7
7
  end
8
8
 
9
9
  it 'should return stored fields' do
10
- Sunspot.search(Post).hits.first.stored(:title).should == 'A Title'
10
+ expect(Sunspot.search(Post).hits.first.stored(:title)).to eq('A Title')
11
11
  end
12
12
  end
@@ -11,7 +11,7 @@ describe 'pagination' do
11
11
 
12
12
  it 'should return all by default' do
13
13
  results = Sunspot.search(Post) { order_by :blog_id }.results
14
- results.should == @posts
14
+ expect(results).to eq(@posts)
15
15
  end
16
16
 
17
17
  it 'should return first page of 10' do
@@ -19,7 +19,7 @@ describe 'pagination' do
19
19
  order_by :blog_id
20
20
  paginate :page => 1, :per_page => 10
21
21
  end.results
22
- results.should == @posts[0,10]
22
+ expect(results).to eq(@posts[0,10])
23
23
  end
24
24
 
25
25
  it 'should return second page of 10' do
@@ -27,7 +27,7 @@ describe 'pagination' do
27
27
  order_by :blog_id
28
28
  paginate :page => 2, :per_page => 10
29
29
  end.results
30
- results.should == @posts[10,10]
30
+ expect(results).to eq(@posts[10,10])
31
31
  end
32
32
 
33
33
  it 'should return pages with offsets' do
@@ -38,6 +38,6 @@ describe 'pagination' do
38
38
 
39
39
  # page 1 is 3, 4, 5, 6, 7
40
40
  # page 2 is 8, 9, 10, 11, 12
41
- results.should == @posts[8,5]
41
+ expect(results).to eq(@posts[8,5])
42
42
  end
43
43
  end
@@ -10,6 +10,6 @@ describe "unicode characters" do
10
10
  end
11
11
 
12
12
  it "correctly retrieves the string as UTF-8" do
13
- Sunspot.search(Post).hits.first.stored(:title).should == "Híghgrøøvé"
13
+ expect(Sunspot.search(Post).hits.first.stored(:title)).to eq("Híghgrøøvé")
14
14
  end
15
15
  end
@@ -85,7 +85,11 @@ Sunspot.setup(Post) do
85
85
 
86
86
  string :legacy_array, :as => :legacy_array_field_sm, :multiple => true do
87
87
  ['first string', 'second string']
88
- end
88
+ end
89
+
90
+ string :tag_list, :multiple => true, :stored => true do
91
+ tags
92
+ end
89
93
  end
90
94
 
91
95
  class PhotoPost < Post
@@ -13,27 +13,32 @@ end
13
13
  require File.join(File.dirname(__FILE__), 'ext')
14
14
 
15
15
  RSpec.configure do |config|
16
- # Run only examples with :focus => true
17
- config.filter_run :focus => true
16
+ config.filter_run :focus
18
17
  config.run_all_when_everything_filtered = true
19
18
 
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = 'random'
24
+
20
25
  # Mock session available to all spec/api tests
21
26
  config.include MockSessionHelper,
22
27
  :type => :api,
23
- :example_group => {:file_path => /spec[\\\/]api/}
28
+ :file_path => /spec[\\\/]api/
24
29
 
25
30
  # Real Solr instance is available to integration tests
26
31
  config.include IntegrationHelper,
27
32
  :type => :integration,
28
- :example_group => {:file_path => /spec[\\\/]integration/}
33
+ :file_path => /spec[\\\/]integration/
29
34
 
30
35
  # Nested under spec/api
31
36
  [:indexer, :query, :search].each do |spec_type|
32
37
  helper_name = "#{spec_type}_helper"
33
38
 
34
39
  config.include Sunspot::Util.full_const_get(Sunspot::Util.camel_case(helper_name)),
35
- :type => spec_type,
36
- :example_group => {:file_path => /spec[\\\/]api[\\\/]#{spec_type}/}
40
+ :type => spec_type,
41
+ :file_path => /spec[\\\/]api[\\\/]#{spec_type}/
37
42
  end
38
43
  end
39
44
 
@@ -30,7 +30,9 @@ Gem::Specification.new do |s|
30
30
  s.add_dependency 'rsolr', '>= 1.1.1', '< 3'
31
31
  s.add_dependency 'pr_geohash', '~>1.0'
32
32
 
33
- s.add_development_dependency 'rspec', '~>2.6.0'
33
+ s.add_development_dependency 'rake', '< 12.3'
34
+ s.add_development_dependency 'rspec'
35
+ s.add_development_dependency 'appraisal', '2.2.0'
34
36
 
35
37
  s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
36
38
  '--title' << 'Sunspot - Solr-powered search for Ruby objects - API Documentation' <<
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -30,7 +30,7 @@ authors:
30
30
  autorequire:
31
31
  bindir: bin
32
32
  cert_chain: []
33
- date: 2016-10-26 00:00:00.000000000 Z
33
+ date: 2018-03-26 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rsolr
@@ -66,20 +66,48 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '12.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '12.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: 2.6.0
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: appraisal
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.2.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
81
109
  - !ruby/object:Gem::Version
82
- version: 2.6.0
110
+ version: 2.2.0
83
111
  description: |2
84
112
  Sunspot is a library providing a powerful, all-ruby API for the Solr search engine. Sunspot manages the configuration of persistent
85
113
  Ruby classes for search and indexing and exposes Solr's most powerful features through a collection of DSLs. Complex search operations
@@ -91,11 +119,14 @@ extensions: []
91
119
  extra_rdoc_files: []
92
120
  files:
93
121
  - ".gitignore"
122
+ - ".rspec"
123
+ - Appraisals
94
124
  - Gemfile
95
125
  - History.txt
96
126
  - LICENSE
97
127
  - Rakefile
98
128
  - TODO
129
+ - gemfiles/.gitkeep
99
130
  - lib/light_config.rb
100
131
  - lib/sunspot.rb
101
132
  - lib/sunspot/adapters.rb
@@ -262,6 +293,7 @@ files:
262
293
  - spec/integration/dynamic_fields_spec.rb
263
294
  - spec/integration/faceting_spec.rb
264
295
  - spec/integration/field_grouping_spec.rb
296
+ - spec/integration/field_lists_spec.rb
265
297
  - spec/integration/geospatial_spec.rb
266
298
  - spec/integration/highlighting_spec.rb
267
299
  - spec/integration/indexing_spec.rb
@@ -316,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
348
  version: '0'
317
349
  requirements: []
318
350
  rubyforge_project: sunspot
319
- rubygems_version: 2.5.0
351
+ rubygems_version: 2.6.13
320
352
  signing_key:
321
353
  specification_version: 4
322
354
  summary: Library for expressive, powerful interaction with the Solr search engine
@@ -386,6 +418,7 @@ test_files:
386
418
  - spec/integration/dynamic_fields_spec.rb
387
419
  - spec/integration/faceting_spec.rb
388
420
  - spec/integration/field_grouping_spec.rb
421
+ - spec/integration/field_lists_spec.rb
389
422
  - spec/integration/geospatial_spec.rb
390
423
  - spec/integration/highlighting_spec.rb
391
424
  - spec/integration/indexing_spec.rb