lisausa-sunspot 1.2.1 → 1.2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -3
- data/Gemfile.lock +32 -0
- data/Rakefile +5 -11
- data/lib/sunspot/dsl/field_query.rb +0 -13
- data/lib/sunspot/dsl/functional.rb +0 -3
- data/lib/sunspot/search/abstract_search.rb +12 -9
- data/lib/sunspot/version.rb +1 -1
- data/solr/etc/jetty.xml +0 -4
- data/spec/api/adapters_spec.rb +1 -1
- data/spec/api/binding_spec.rb +1 -1
- data/spec/api/indexer/attributes_spec.rb +1 -1
- data/spec/api/indexer/batch_spec.rb +1 -1
- data/spec/api/indexer/dynamic_fields_spec.rb +1 -1
- data/spec/api/indexer/fixed_fields_spec.rb +1 -1
- data/spec/api/indexer/fulltext_spec.rb +1 -1
- data/spec/api/indexer/removal_spec.rb +1 -1
- data/spec/api/indexer/spec_helper.rb +1 -1
- data/spec/api/indexer_spec.rb +1 -1
- data/spec/api/query/advanced_manipulation_examples.rb +1 -1
- data/spec/api/query/dsl_spec.rb +1 -1
- data/spec/api/query/faceting_examples.rb +2 -0
- data/spec/api/query/fulltext_examples.rb +2 -0
- data/spec/api/query/function_spec.rb +1 -1
- data/spec/api/query/geo_examples.rb +1 -0
- data/spec/api/query/highlighting_examples.rb +2 -0
- data/spec/api/query/more_like_this_spec.rb +1 -1
- data/spec/api/query/ordering_pagination_examples.rb +2 -0
- data/spec/api/query/spec_helper.rb +1 -1
- data/spec/api/query/standard_spec.rb +1 -1
- data/spec/api/search/dynamic_fields_spec.rb +1 -1
- data/spec/api/search/faceting_spec.rb +1 -1
- data/spec/api/search/highlighting_spec.rb +1 -1
- data/spec/api/search/hits_spec.rb +32 -12
- data/spec/api/search/results_spec.rb +19 -6
- data/spec/api/search/search_spec.rb +1 -1
- data/spec/api/search/spec_helper.rb +1 -1
- data/spec/api/server_spec.rb +1 -1
- data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +1 -1
- data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +1 -1
- data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +1 -1
- data/spec/api/session_proxy/sharding_session_proxy_spec.rb +1 -1
- data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +1 -1
- data/spec/api/session_proxy/spec_helper.rb +1 -1
- data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +1 -1
- data/spec/api/session_spec.rb +1 -1
- data/spec/api/spec_helper.rb +1 -1
- data/spec/api/sunspot_spec.rb +1 -1
- data/spec/integration/faceting_spec.rb +1 -1
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/keyword_search_spec.rb +1 -1
- data/spec/integration/local_search_spec.rb +1 -1
- data/spec/integration/more_like_this_spec.rb +1 -1
- data/spec/integration/scoped_search_spec.rb +1 -1
- data/spec/integration/spec_helper.rb +1 -1
- data/spec/integration/test_pagination.rb +1 -1
- data/spec/mocks/connection.rb +1 -1
- data/spec/spec_helper.rb +16 -4
- metadata +36 -119
- data/.gitignore +0 -12
- data/lib/sunspot/search/paginated_collection.rb +0 -55
- data/script/console +0 -10
- data/solr-1.3/etc/jetty.xml +0 -212
- data/solr-1.3/etc/webdefault.xml +0 -379
- data/solr-1.3/lib/jetty-6.1.3.jar +0 -0
- data/solr-1.3/lib/jetty-util-6.1.3.jar +0 -0
- data/solr-1.3/lib/jsp-2.1/ant-1.6.5.jar +0 -0
- data/solr-1.3/lib/jsp-2.1/core-3.1.1.jar +0 -0
- data/solr-1.3/lib/jsp-2.1/jsp-2.1.jar +0 -0
- data/solr-1.3/lib/jsp-2.1/jsp-api-2.1.jar +0 -0
- data/solr-1.3/lib/servlet-api-2.5-6.1.3.jar +0 -0
- data/solr-1.3/solr/conf/elevate.xml +0 -36
- data/solr-1.3/solr/conf/protwords.txt +0 -21
- data/solr-1.3/solr/conf/schema.xml +0 -64
- data/solr-1.3/solr/conf/solrconfig.xml +0 -725
- data/solr-1.3/solr/conf/stopwords.txt +0 -57
- data/solr-1.3/solr/conf/synonyms.txt +0 -31
- data/solr-1.3/solr/lib/geoapi-nogenerics-2.1-M2.jar +0 -0
- data/solr-1.3/solr/lib/gt2-referencing-2.3.1.jar +0 -0
- data/solr-1.3/solr/lib/jsr108-0.01.jar +0 -0
- data/solr-1.3/solr/lib/locallucene.jar +0 -0
- data/solr-1.3/solr/lib/localsolr.jar +0 -0
- data/solr-1.3/start.jar +0 -0
- data/solr-1.3/webapps/solr.war +0 -0
- data/solr/README.txt +0 -42
- data/solr/solr/.gitignore +0 -1
- data/solr/solr/README.txt +0 -54
- data/solr/solr/conf/xslt/example.xsl +0 -132
- data/solr/solr/conf/xslt/example_atom.xsl +0 -67
- data/solr/solr/conf/xslt/example_rss.xsl +0 -66
- data/solr/solr/conf/xslt/luke.xsl +0 -337
- data/spec/api/search/paginated_collection_spec.rb +0 -26
data/Gemfile
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source :rubygems
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require File.expand_path('../lib/sunspot/version', __FILE__)
|
4
|
+
|
5
|
+
gem 'sunspot', Sunspot::VERSION, :path => File.expand_path('..', __FILE__)
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem 'rspec', '~> 1.3'
|
9
|
+
gem 'ruby-debug'
|
10
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sunspot (1.2.0)
|
5
|
+
escape (= 0.0.4)
|
6
|
+
pr_geohash (~> 1.0)
|
7
|
+
rsolr (= 0.12.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
builder (3.0.0)
|
13
|
+
columnize (0.3.2)
|
14
|
+
escape (0.0.4)
|
15
|
+
linecache (0.43)
|
16
|
+
pr_geohash (1.0.0)
|
17
|
+
rsolr (0.12.1)
|
18
|
+
builder (>= 2.1.2)
|
19
|
+
rspec (1.3.0)
|
20
|
+
ruby-debug (0.10.3)
|
21
|
+
columnize (>= 0.1)
|
22
|
+
ruby-debug-base (~> 0.10.3.0)
|
23
|
+
ruby-debug-base (0.10.3)
|
24
|
+
linecache (>= 0.3)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
rspec (~> 1.3)
|
31
|
+
ruby-debug
|
32
|
+
sunspot (= 1.2.0)!
|
data/Rakefile
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
ENV['RUBYOPT'] = '-W1'
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
3
|
+
task :environment do
|
4
|
+
require File.dirname(__FILE__) + '/lib/sunspot'
|
5
|
+
end
|
6
6
|
|
7
|
-
require '
|
7
|
+
require File.join(File.dirname(__FILE__), 'lib', 'sunspot', 'version')
|
8
8
|
|
9
9
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
10
10
|
|
11
|
-
|
12
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
13
|
-
t.spec_files = Dir.glob('spec/**/*_spec.rb')
|
14
|
-
t.spec_opts << '--format specdoc'
|
15
|
-
end
|
16
|
-
|
17
|
-
task :default => 'spec'
|
11
|
+
task :default => 'spec:api'
|
@@ -84,19 +84,6 @@ module Sunspot
|
|
84
84
|
# with a category_id of 2, the category_id facet will operate as if a
|
85
85
|
# category had not been selected, allowing the user to select additional
|
86
86
|
# categories (which will presumably be ORed together).
|
87
|
-
#
|
88
|
-
# It possible to exclude multiple filters by passing an array:
|
89
|
-
#
|
90
|
-
# Sunspot.search(Post) do
|
91
|
-
# with(:blog_id, 1)
|
92
|
-
# category_filter = with(:category_id, 2)
|
93
|
-
# author_filter = with(:author_id, 3)
|
94
|
-
# facet(:category_id,
|
95
|
-
# :exclude => [category_filter, author_filter].compact)
|
96
|
-
# end
|
97
|
-
#
|
98
|
-
# You should consider using +.compact+ to ensure that the array does not
|
99
|
-
# contain any nil values.
|
100
87
|
#
|
101
88
|
# <strong>As far as I can tell, Solr only supports multi-select with
|
102
89
|
# field facets; if +:exclude+ is passed to a query facet, this method will
|
@@ -14,9 +14,6 @@ module Sunspot
|
|
14
14
|
# function { :average_rating }
|
15
15
|
# function { sum(:average_rating, 10) }
|
16
16
|
#
|
17
|
-
# See http://wiki.apache.org/solr/FunctionQuery for a list of all
|
18
|
-
# applicable functions
|
19
|
-
#
|
20
17
|
def function(&block)
|
21
18
|
expression = Sunspot::Util.instance_eval_or_call(
|
22
19
|
Function.new(self),
|
@@ -1,8 +1,5 @@
|
|
1
|
-
require 'sunspot/search/paginated_collection'
|
2
|
-
|
3
1
|
module Sunspot
|
4
2
|
module Search #:nodoc:
|
5
|
-
|
6
3
|
#
|
7
4
|
# This class encapsulates the results of a Solr search. It provides access
|
8
5
|
# to search results, total result count, facets, and pagination information.
|
@@ -35,7 +32,7 @@ module Sunspot
|
|
35
32
|
def execute
|
36
33
|
reset
|
37
34
|
params = @query.to_params
|
38
|
-
@solr_result = @connection.request("/#{request_handler}", params
|
35
|
+
@solr_result = @connection.request("/#{request_handler}", params)
|
39
36
|
self
|
40
37
|
end
|
41
38
|
|
@@ -56,7 +53,7 @@ module Sunspot
|
|
56
53
|
# WillPaginate::Collection or Array:: Instantiated result objects
|
57
54
|
#
|
58
55
|
def results
|
59
|
-
@results ||=
|
56
|
+
@results ||= maybe_will_paginate(verified_hits.map { |hit| hit.instance })
|
60
57
|
end
|
61
58
|
|
62
59
|
#
|
@@ -87,7 +84,7 @@ module Sunspot
|
|
87
84
|
Hit.new(doc, highlights_for(doc), self)
|
88
85
|
end
|
89
86
|
end
|
90
|
-
|
87
|
+
maybe_will_paginate(hits || [])
|
91
88
|
end
|
92
89
|
end
|
93
90
|
end
|
@@ -272,11 +269,17 @@ module Sunspot
|
|
272
269
|
end
|
273
270
|
|
274
271
|
def verified_hits
|
275
|
-
@verified_hits ||=
|
272
|
+
@verified_hits ||= maybe_will_paginate(hits.select { |hit| hit.instance })
|
276
273
|
end
|
277
274
|
|
278
|
-
def
|
279
|
-
|
275
|
+
def maybe_will_paginate(collection)
|
276
|
+
if defined?(WillPaginate::Collection)
|
277
|
+
WillPaginate::Collection.create(@query.page, @query.per_page, total) do |pager|
|
278
|
+
pager.replace(collection)
|
279
|
+
end
|
280
|
+
else
|
281
|
+
collection
|
282
|
+
end
|
280
283
|
end
|
281
284
|
|
282
285
|
def add_facet(name, facet)
|
data/lib/sunspot/version.rb
CHANGED
data/solr/etc/jetty.xml
CHANGED
@@ -73,10 +73,6 @@
|
|
73
73
|
<Set name="port"><SystemProperty name="jetty.port" default="8983"/></Set>
|
74
74
|
<Set name="maxIdleTime">50000</Set>
|
75
75
|
<Set name="lowResourceMaxIdleTime">1500</Set>
|
76
|
-
<!-- Increase header buffer size from default of 4KB to 64KB to
|
77
|
-
prevent Solr from reaching this limit during large queries
|
78
|
-
-->
|
79
|
-
<Set name="headerBufferSize">65536</Set>
|
80
76
|
</New>
|
81
77
|
</Arg>
|
82
78
|
</Call>
|
data/spec/api/adapters_spec.rb
CHANGED
data/spec/api/binding_spec.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
data/spec/api/indexer_spec.rb
CHANGED
data/spec/api/query/dsl_spec.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
3
|
describe 'hits', :type => :search do
|
4
4
|
it 'should return hits without loading instances' do
|
@@ -12,18 +12,38 @@ describe 'hits', :type => :search do
|
|
12
12
|
end.should == [['Post', post_1.id.to_s], ['Post', post_2.id.to_s]]
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if ENV['USE_WILL_PAGINATE']
|
16
|
+
|
17
|
+
it 'returns search total as attribute of hits' do
|
18
|
+
stub_results(Post.new, 4)
|
19
|
+
session.search(Post) do
|
20
|
+
paginate(:page => 1)
|
21
|
+
end.hits.total_entries.should == 4
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns search total as attribute of verified hits' do
|
25
|
+
stub_results(Post.new, 4)
|
26
|
+
session.search(Post) do
|
27
|
+
paginate(:page => 1)
|
28
|
+
end.hits(:verify => true).total_entries.should == 4
|
29
|
+
end
|
30
|
+
|
31
|
+
else
|
32
|
+
|
33
|
+
it 'returns vanilla array of hits if WillPaginate is not available' do
|
34
|
+
stub_results(Post.new)
|
35
|
+
session.search(Post) do
|
36
|
+
paginate(:page => 1)
|
37
|
+
end.hits.should_not respond_to(:total_entries)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns vanilla array of verified hits if WillPaginate is not available' do
|
41
|
+
stub_results(Post.new)
|
42
|
+
session.search(Post) do
|
43
|
+
paginate(:page => 1)
|
44
|
+
end.hits(:verified => true).should_not respond_to(:total_entries)
|
45
|
+
end
|
21
46
|
|
22
|
-
it 'returns search total as attribute of verified hits' do
|
23
|
-
stub_results(Post.new, 4)
|
24
|
-
session.search(Post) do
|
25
|
-
paginate(:page => 1)
|
26
|
-
end.hits(:verify => true).total_entries.should == 4
|
27
47
|
end
|
28
48
|
|
29
49
|
it 'should return instance from hit' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
3
|
describe 'search results', :type => :search do
|
4
4
|
it 'loads single result' do
|
@@ -30,11 +30,24 @@ describe 'search results', :type => :search do
|
|
30
30
|
session.search(Post).results.should == []
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
if ENV['USE_WILL_PAGINATE']
|
34
|
+
|
35
|
+
it 'returns search total as attribute of results' do
|
36
|
+
stub_results(Post.new, 4)
|
37
|
+
session.search(Post) do
|
38
|
+
paginate(:page => 1)
|
39
|
+
end.results.total_entries.should == 4
|
40
|
+
end
|
41
|
+
|
42
|
+
else
|
43
|
+
|
44
|
+
it 'returns vanilla array if WillPaginate is not available' do
|
45
|
+
stub_results(Post.new)
|
46
|
+
session.search(Post) do
|
47
|
+
paginate(:page => 1)
|
48
|
+
end.results.should_not respond_to(:total_entries)
|
49
|
+
end
|
50
|
+
|
38
51
|
end
|
39
52
|
|
40
53
|
it 'returns total' do
|
@@ -1 +1 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
data/spec/api/server_spec.rb
CHANGED