sunspot 1.1.0 → 1.2.0
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.
- data/Gemfile +10 -0
- data/Gemfile.lock +32 -0
- data/History.txt +24 -0
- data/README.rdoc +18 -5
- data/lib/sunspot.rb +40 -0
- data/lib/sunspot/dsl.rb +2 -2
- data/lib/sunspot/dsl/field_query.rb +2 -2
- data/lib/sunspot/dsl/fields.rb +0 -10
- data/lib/sunspot/dsl/restriction.rb +4 -4
- data/lib/sunspot/dsl/restriction_with_near.rb +121 -0
- data/lib/sunspot/dsl/scope.rb +55 -67
- data/lib/sunspot/dsl/standard_query.rb +11 -15
- data/lib/sunspot/field.rb +30 -29
- data/lib/sunspot/field_factory.rb +0 -18
- data/lib/sunspot/installer/solrconfig_updater.rb +0 -30
- data/lib/sunspot/query.rb +4 -3
- data/lib/sunspot/query/common_query.rb +2 -2
- data/lib/sunspot/query/composite_fulltext.rb +7 -2
- data/lib/sunspot/query/connective.rb +21 -6
- data/lib/sunspot/query/dismax.rb +1 -0
- data/lib/sunspot/query/geo.rb +53 -0
- data/lib/sunspot/query/more_like_this.rb +1 -0
- data/lib/sunspot/query/restriction.rb +5 -5
- data/lib/sunspot/query/standard_query.rb +0 -4
- data/lib/sunspot/search/abstract_search.rb +1 -7
- data/lib/sunspot/search/hit.rb +10 -10
- data/lib/sunspot/search/query_facet.rb +8 -3
- data/lib/sunspot/session.rb +10 -2
- data/lib/sunspot/session_proxy.rb +16 -0
- data/lib/sunspot/session_proxy/master_slave_session_proxy.rb +1 -1
- data/lib/sunspot/session_proxy/sharding_session_proxy.rb +7 -0
- data/lib/sunspot/session_proxy/silent_fail_session_proxy.rb +42 -0
- data/lib/sunspot/session_proxy/thread_local_session_proxy.rb +1 -1
- data/lib/sunspot/setup.rb +1 -17
- data/lib/sunspot/type.rb +38 -6
- data/lib/sunspot/util.rb +21 -31
- data/lib/sunspot/version.rb +1 -1
- data/solr/solr/conf/solrconfig.xml +0 -4
- data/spec/api/binding_spec.rb +12 -0
- data/spec/api/indexer/attributes_spec.rb +22 -22
- data/spec/api/query/connectives_examples.rb +14 -1
- data/spec/api/query/fulltext_examples.rb +3 -3
- data/spec/api/query/geo_examples.rb +69 -0
- data/spec/api/query/scope_examples.rb +32 -13
- data/spec/api/query/standard_spec.rb +1 -1
- data/spec/api/search/faceting_spec.rb +5 -1
- data/spec/api/search/hits_spec.rb +14 -12
- data/spec/api/session_proxy/class_sharding_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 +24 -0
- data/spec/api/session_spec.rb +22 -0
- data/spec/integration/local_search_spec.rb +42 -69
- data/spec/integration/scoped_search_spec.rb +30 -0
- data/spec/mocks/connection.rb +6 -2
- data/spec/mocks/photo.rb +0 -1
- data/spec/mocks/post.rb +11 -2
- data/spec/mocks/user.rb +6 -1
- data/spec/spec_helper.rb +2 -12
- metadata +209 -177
- data/lib/sunspot/query/local.rb +0 -26
- data/solr/solr/lib/lucene-spatial-2.9.1.jar +0 -0
- data/solr/solr/lib/solr-spatial-light-0.0.6.jar +0 -0
- data/spec/api/query/local_examples.rb +0 -38
- data/tasks/gemspec.rake +0 -33
- data/tasks/rcov.rake +0 -28
- data/tasks/spec.rake +0 -24
data/lib/sunspot/query/local.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Sunspot
|
2
|
-
module Query
|
3
|
-
#
|
4
|
-
# This query component generates parameters for LocalSolr geo-radial
|
5
|
-
# searches. The LocalSolr API is fairly rigid, so the Local component
|
6
|
-
# doesn't have any options - it just takes coordinates and a radius, and
|
7
|
-
# generates the appropriate parameters.
|
8
|
-
#
|
9
|
-
class Local #:nodoc:
|
10
|
-
def initialize(coordinates, options)
|
11
|
-
@coordinates, @options = Util::Coordinates.new(coordinates), options
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_params
|
15
|
-
local_params = [
|
16
|
-
[:radius, @options[:distance]],
|
17
|
-
[:sort, @options[:sort]]
|
18
|
-
].map do |key,value|
|
19
|
-
"#{key}=#{value}" if value
|
20
|
-
end.compact.join(" ") #TODO Centralized local param builder
|
21
|
-
query = "{!#{local_params}}#{@coordinates.lat},#{@coordinates.lng}"
|
22
|
-
{ :spatial => query }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
Binary file
|
Binary file
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
shared_examples_for "spatial query" do
|
4
|
-
it 'sends lat and lng, and distance when geo search is performed' do
|
5
|
-
search do
|
6
|
-
near [40.7, -73.5], :distance => 5
|
7
|
-
end
|
8
|
-
connection.should have_last_search_with(:spatial => "{!radius=5}40.7,-73.5")
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'sets lat, lng, and sort flag when sorted geo search is performed' do
|
12
|
-
search do
|
13
|
-
near [40.7, -73.5], :sort => true
|
14
|
-
end
|
15
|
-
connection.should have_last_search_with(:spatial => "{!sort=true}40.7,-73.5")
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'sets radius and sort when both are specified' do
|
19
|
-
search do
|
20
|
-
near [40.7, -73.5], :distance => 5, :sort => true
|
21
|
-
end
|
22
|
-
connection.should have_last_search_with(:spatial => "{!radius=5 sort=true}40.7,-73.5")
|
23
|
-
end
|
24
|
-
|
25
|
-
[
|
26
|
-
[:lat, :lng],
|
27
|
-
[:lat, :lon],
|
28
|
-
[:lat, :long],
|
29
|
-
[:latitude, :longitude]
|
30
|
-
].each do |lat_attr, lng_attr|
|
31
|
-
it "sets coordinates using #{lat_attr.inspect}, #{lng_attr.inspect}" do
|
32
|
-
search do
|
33
|
-
near OpenStruct.new(lat_attr => 40.7, lng_attr => -73.5), :distance => 5
|
34
|
-
end
|
35
|
-
connection.should have_last_search_with(:spatial => "{!radius=5}40.7,-73.5")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/tasks/gemspec.rake
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'tools', 'gem_tasks')
|
2
|
-
|
3
|
-
Sunspot::GemTasks.new(:build => :copy_rdoc) do |s|
|
4
|
-
s.name = 'sunspot'
|
5
|
-
s.version = Sunspot::VERSION
|
6
|
-
s.executables = ['sunspot-solr', 'sunspot-installer']
|
7
|
-
s.email = 'mat@patch.com'
|
8
|
-
s.homepage = 'http://outoftime.github.com/sunspot'
|
9
|
-
s.summary = 'Library for expressive, powerful interaction with the Solr search engine'
|
10
|
-
s.description = <<TEXT
|
11
|
-
Sunspot is a library providing a powerful, all-ruby API for the Solr search engine. Sunspot manages the configuration of persistent Ruby classes for search and indexing and exposes Solr's most powerful features through a collection of DSLs. Complex search operations can be performed without hand-writing any boolean queries or building Solr parameters by hand.
|
12
|
-
TEXT
|
13
|
-
s.authors = ['Mat Brown', 'Peer Allan', 'Dmitriy Dzema', 'Benjamin Krause', 'Marcel de Graaf', 'Brandon Keepers', 'Peter Berkenbosch', 'Brian Atkinson', 'Tom Coleman', 'Matt Mitchell', 'Nathan Beyer', 'Kieran Topping', 'Nicolas Braem', 'Jeremy Ashkenas']
|
14
|
-
s.rubyforge_project = 'sunspot'
|
15
|
-
s.files = FileList['[A-Z]*', '{bin,installer,lib,spec,tasks,templates}/**/*', 'solr/{etc,lib,webapps}/**/*', 'solr/solr/{conf,lib}/*', 'solr/start.jar']
|
16
|
-
s.add_runtime_dependency 'rsolr', '0.12.1'
|
17
|
-
s.add_runtime_dependency 'escape', '0.0.4'
|
18
|
-
s.add_development_dependency 'rspec', '~> 1.1'
|
19
|
-
s.extra_rdoc_files = ['README.rdoc']
|
20
|
-
s.test_files = FileList['spec/**/*_spec.rb']
|
21
|
-
s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
|
22
|
-
'--title' << 'Sunspot - Solr-powered search for Ruby objects - API Documentation' <<
|
23
|
-
'--main' << 'README.rdoc'
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
task :copy_rdoc do
|
28
|
-
sunspot_root = File.join(File.dirname(__FILE__), '..')
|
29
|
-
FileUtils.cp(
|
30
|
-
File.join(sunspot_root, '..', 'README.rdoc'),
|
31
|
-
sunspot_root
|
32
|
-
)
|
33
|
-
end
|
data/tasks/rcov.rake
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'spec/rake/spectask'
|
3
|
-
|
4
|
-
desc 'run specs with rcov'
|
5
|
-
Spec::Rake::SpecTask.new('rcov') do |t|
|
6
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
7
|
-
t.rcov = true
|
8
|
-
t.rcov_dir = File.join('coverage', 'all')
|
9
|
-
t.rcov_opts.concat(['--exclude', 'spec', '--sort', 'coverage', '--only-uncovered'])
|
10
|
-
end
|
11
|
-
|
12
|
-
namespace :rcov do
|
13
|
-
desc 'run api specs with rcov'
|
14
|
-
Spec::Rake::SpecTask.new('api') do |t|
|
15
|
-
t.spec_files = FileList['spec/api/**/*_spec.rb']
|
16
|
-
t.rcov = true
|
17
|
-
t.rcov_dir = File.join('coverage', 'api')
|
18
|
-
t.rcov_opts.concat(['--exclude', 'spec', '--sort', 'coverage', '--only-uncovered'])
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'run integration specs with rcov'
|
22
|
-
Spec::Rake::SpecTask.new('integration') do |t|
|
23
|
-
t.spec_files = FileList['spec/integration/**/*_spec.rb']
|
24
|
-
t.rcov = true
|
25
|
-
t.rcov_dir = File.join('coverage', 'integration')
|
26
|
-
t.rcov_opts.concat(['--exclude', 'spec', '--sort', 'coverage', '--only-uncovered'])
|
27
|
-
end
|
28
|
-
end
|
data/tasks/spec.rake
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
gem 'rspec', '~>1.1'
|
2
|
-
|
3
|
-
require 'spec'
|
4
|
-
require 'spec/rake/spectask'
|
5
|
-
|
6
|
-
desc 'run specs'
|
7
|
-
Spec::Rake::SpecTask.new('spec') do |t|
|
8
|
-
t.spec_files = FileList[File.join(File.dirname(__FILE__), '..', 'spec', '**', '*_spec.rb')]
|
9
|
-
t.spec_opts = ['--color']
|
10
|
-
end
|
11
|
-
|
12
|
-
namespace :spec do
|
13
|
-
desc 'run api specs (mock out Solr dependency)'
|
14
|
-
Spec::Rake::SpecTask.new('api') do |t|
|
15
|
-
t.spec_files = FileList[File.join(File.dirname(__FILE__), '..', 'spec', 'api', '**', '*_spec.rb')]
|
16
|
-
t.spec_opts = ['--color']
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'run integration specs (be sure to run `bin/sunspot-solr start`)'
|
20
|
-
Spec::Rake::SpecTask.new('integration') do |t|
|
21
|
-
t.spec_files = FileList[File.join(File.dirname(__FILE__), '..', 'spec', 'integration', '*_spec.rb')]
|
22
|
-
t.spec_opts = ['--color']
|
23
|
-
end
|
24
|
-
end
|