ultrasphinx 1.8 → 1.9
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.tar.gz.sig +1 -3
- data/CHANGELOG +4 -0
- data/DEPLOYMENT_NOTES +7 -3
- data/Manifest +10 -0
- data/RAKE_TASKS +4 -2
- data/README +35 -18
- data/TODO +0 -1
- data/examples/default.base +24 -19
- data/lib/ultrasphinx.rb +1 -1
- data/lib/ultrasphinx/configure.rb +66 -25
- data/lib/ultrasphinx/core_extensions.rb +10 -1
- data/lib/ultrasphinx/is_indexed.rb +49 -6
- data/lib/ultrasphinx/search.rb +81 -69
- data/lib/ultrasphinx/search/internals.rb +61 -38
- data/lib/ultrasphinx/search/parser.rb +17 -7
- data/lib/ultrasphinx/ultrasphinx.rb +69 -16
- data/tasks/ultrasphinx.rake +47 -29
- data/test/config/ultrasphinx/test.base +50 -21
- data/test/integration/app/app/models/geo/address.rb +2 -1
- data/test/integration/app/app/models/person/user.rb +12 -3
- data/test/integration/app/app/models/seller.rb +2 -1
- data/test/integration/app/config/environment.rb +2 -0
- data/test/integration/app/config/ultrasphinx/default.base +16 -8
- data/test/integration/app/config/ultrasphinx/development.conf +319 -0
- data/test/integration/app/config/ultrasphinx/development.conf.canonical +152 -24
- data/test/integration/app/db/schema.rb +56 -0
- data/test/integration/app/test/fixtures/sellers.yml +1 -1
- data/test/integration/app/test/fixtures/users.yml +1 -1
- data/test/integration/app/test/unit/country_test.rb +8 -0
- data/test/integration/delta_test.rb +39 -0
- data/test/integration/search_test.rb +60 -1
- data/test/integration/spell_test.rb +6 -2
- data/test/profile/benchmark.rb +44 -0
- data/test/test_helper.rb +6 -1
- data/test/unit/parser_test.rb +21 -2
- data/ultrasphinx.gemspec +4 -4
- data/vendor/riddle/README +2 -2
- data/vendor/riddle/lib/riddle.rb +1 -1
- data/vendor/riddle/lib/riddle/client.rb +45 -10
- data/vendor/riddle/spec/fixtures/data/anchor.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/any.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/boolean.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/distinct.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/field_weights.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/filter.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/group.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/index.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/index_weights.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/phrase.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/rank_mode.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/simple.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/sort.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/update_simple.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/weights.bin +0 -0
- data/vendor/riddle/spec/fixtures/data_generator.php +130 -0
- data/vendor/riddle/spec/fixtures/sphinxapi.php +1066 -0
- data/vendor/riddle/spec/spec_helper.rb +1 -0
- data/vendor/riddle/spec/unit/client_spec.rb +18 -4
- metadata +12 -2
- metadata.gz.sig +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
+
# please use the migrations feature of ActiveRecord to incrementally modify your database, and
|
3
|
+
# then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
+
#
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
11
|
+
|
12
|
+
ActiveRecord::Schema.define(:version => 9) do
|
13
|
+
|
14
|
+
create_table "addresses", :force => true do |t|
|
15
|
+
t.integer "user_id", :null => false
|
16
|
+
t.string "name"
|
17
|
+
t.string "line_1", :default => "", :null => false
|
18
|
+
t.string "line_2"
|
19
|
+
t.string "city", :default => "", :null => false
|
20
|
+
t.integer "state_id", :null => false
|
21
|
+
t.string "province_region"
|
22
|
+
t.string "zip_postal_code"
|
23
|
+
t.integer "country_id", :null => false
|
24
|
+
t.float "lat"
|
25
|
+
t.float "long"
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table "countries", :force => true do |t|
|
29
|
+
t.string "name", :default => "", :null => false
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table "sellers", :force => true do |t|
|
33
|
+
t.integer "user_id", :null => false
|
34
|
+
t.string "company_name"
|
35
|
+
t.datetime "created_at"
|
36
|
+
t.datetime "updated_at"
|
37
|
+
t.float "capitalization", :default => 0.0
|
38
|
+
t.string "mission_statement"
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table "states", :force => true do |t|
|
42
|
+
t.string "name", :default => "", :null => false
|
43
|
+
t.string "abbreviation", :default => "", :null => false
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table "users", :force => true do |t|
|
47
|
+
t.string "login", :limit => 64, :default => "", :null => false
|
48
|
+
t.string "email", :default => "", :null => false
|
49
|
+
t.string "crypted_password", :limit => 64, :default => "", :null => false
|
50
|
+
t.string "salt", :limit => 64, :default => "", :null => false
|
51
|
+
t.datetime "created_at"
|
52
|
+
t.datetime "updated_at"
|
53
|
+
t.boolean "deleted", :default => false
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
company_name: <%= "seller#{num}" %>
|
6
6
|
capitalization: <%= num * 1.548 %>
|
7
7
|
mission_statement: <%= %w(Add value through developing superior products.).sort_by(&:rand).join(" ") %>
|
8
|
-
updated_at: <%= ((time = Time.parse("Tue Oct 23 04:28:11")) - num.days).to_s(:db) %>
|
8
|
+
updated_at: <%= ((time = Time.parse("Tue Oct 23 04:28:11 2007")) - num.days).to_s(:db) %>
|
9
9
|
created_at: <%= (time - num.weeks).to_s(:db) %>
|
10
10
|
<% end %>
|
11
11
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
crypted_password: "2fdefe5c83d80a03a828dd65e90cfff65f0fb42d043a254ca2cad6af968d0e15" #password
|
6
6
|
email: <%= "user#{num}@test.com" %>
|
7
7
|
salt: "1000"
|
8
|
-
updated_at: <%= (time = Time.parse("Tue Oct 23 04:28:11")).to_s(:db) %>
|
8
|
+
updated_at: <%= (time = Time.parse("Tue Oct 23 04:28:11 2007")).to_s(:db) %>
|
9
9
|
created_at: <%= (time - 180).to_s(:db) %>
|
10
10
|
deleted: <%= num == 41 ? true : false %>
|
11
11
|
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
require "#{File.dirname(__FILE__)}/../test_helper"
|
3
|
+
|
4
|
+
class DeltaTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
S = Ultrasphinx::Search
|
7
|
+
E = Ultrasphinx::UsageError
|
8
|
+
STRFTIME = "%b %d %Y %H:%M:%S" # Chronic can't parse the default date .to_s
|
9
|
+
|
10
|
+
def test_delta_update
|
11
|
+
|
12
|
+
# XXX Not really necessary?
|
13
|
+
Dir.chdir "#{HERE}/integration/app" do
|
14
|
+
Echoe.silence do
|
15
|
+
system("rake db:fixtures:load")
|
16
|
+
system("rake ultrasphinx:index")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
@count = S.new.total_entries
|
21
|
+
|
22
|
+
@new = User.new
|
23
|
+
@new.save!
|
24
|
+
User.find(2).update_attribute(:created_at, Time.now)
|
25
|
+
|
26
|
+
Dir.chdir "#{HERE}/integration/app" do
|
27
|
+
Echoe.silence { system("rake ultrasphinx:index:delta") }
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal @count + 1, S.new.total_entries
|
31
|
+
@new.destroy
|
32
|
+
|
33
|
+
Dir.chdir "#{HERE}/integration/app" do
|
34
|
+
Echoe.silence { system("rake ultrasphinx:index:delta") }
|
35
|
+
end
|
36
|
+
|
37
|
+
assert_equal @count, S.new.total_entries
|
38
|
+
end
|
39
|
+
end
|
@@ -16,8 +16,20 @@ class SearchTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
def test_with_subtotals_option
|
18
18
|
S.client_options['with_subtotals'] = true
|
19
|
-
|
19
|
+
|
20
|
+
# No delta index; accurate subtotals sum
|
21
|
+
@s = S.new(:indexes => Ultrasphinx::MAIN_INDEX).run
|
20
22
|
assert_equal @s.total_entries, @s.subtotals.values._sum
|
23
|
+
|
24
|
+
# With delta; subtotals sum not less than total sum
|
25
|
+
@s = S.new.run
|
26
|
+
assert @s.subtotals.values._sum >= @s.total_entries
|
27
|
+
|
28
|
+
# With delta and filter; request class gets accurate count regardless
|
29
|
+
@s = S.new(:class_names => 'Seller').run
|
30
|
+
assert_equal @s.total_entries, @s.subtotals['Seller']
|
31
|
+
assert @s.subtotals.values._sum >= @s.total_entries
|
32
|
+
|
21
33
|
S.client_options['with_subtotals'] = false
|
22
34
|
end
|
23
35
|
|
@@ -84,6 +96,34 @@ class SearchTest < Test::Unit::TestCase
|
|
84
96
|
)
|
85
97
|
end
|
86
98
|
|
99
|
+
def test_individual_totals_with_pagination
|
100
|
+
Ultrasphinx::MODEL_CONFIGURATION.keys.each do |class_name|
|
101
|
+
if class_name == "User"
|
102
|
+
assert_equal User.count(:conditions => {:deleted => false }),
|
103
|
+
S.new(:class_names => class_name, :page => 2).total_entries
|
104
|
+
else
|
105
|
+
assert_equal class_name.constantize.count,
|
106
|
+
S.new(:class_names => class_name, :page => 2).total_entries
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_individual_totals_without_pagination
|
112
|
+
Ultrasphinx::MODEL_CONFIGURATION.keys.each do |class_name|
|
113
|
+
begin
|
114
|
+
if class_name == "User"
|
115
|
+
assert_equal User.count(:conditions => {:deleted => false }),
|
116
|
+
S.new(:class_names => class_name).total_entries
|
117
|
+
else
|
118
|
+
assert_equal class_name.constantize.count,
|
119
|
+
S.new(:class_names => class_name).total_entries
|
120
|
+
end
|
121
|
+
rescue Object
|
122
|
+
raise class_name
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
87
127
|
def test_sort_by_date
|
88
128
|
assert_equal(
|
89
129
|
Seller.find(:all, :limit => 5, :order => 'created_at DESC').map(&:created_at),
|
@@ -211,6 +251,25 @@ class SearchTest < Test::Unit::TestCase
|
|
211
251
|
@s.facets['company_name'].size
|
212
252
|
)
|
213
253
|
end
|
254
|
+
|
255
|
+
def test_included_text_facet_without_association_sql
|
256
|
+
# there are 40 users, but only 20 sellers. So you get 20 facets + 1 nil with 20 items
|
257
|
+
@s = Ultrasphinx::Search.new(:class_names => 'User', :facets => ['company']).run
|
258
|
+
assert_equal(
|
259
|
+
(Seller.count + 1),
|
260
|
+
@s.facets['company'].size
|
261
|
+
)
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_included_text_facet_with_association_sql
|
265
|
+
# XXX there are 40 users but only 20 sellers, but the replace function from user deletes
|
266
|
+
# User #6 and 16 (why?). There is also a nil facet that gets added for a total of 19 objects
|
267
|
+
@s = Ultrasphinx::Search.new(:class_names => 'User', :facets => ['company_two']).run
|
268
|
+
assert_equal(
|
269
|
+
(Seller.count - 1),
|
270
|
+
@s.facets['company_two'].size
|
271
|
+
)
|
272
|
+
end
|
214
273
|
|
215
274
|
def test_numeric_facet
|
216
275
|
@user_id_count = Seller.find(:all).map(&:user_id).uniq.size
|
@@ -8,8 +8,12 @@ class SpellTest < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_spelling
|
11
|
-
|
12
|
-
|
11
|
+
if defined?(Aspell)
|
12
|
+
assert_equal nil, Ultrasphinx::Spell.correct("correct words")
|
13
|
+
assert_equal "garbled words", Ultrasphinx::Spell.correct("glarbled words")
|
14
|
+
else
|
15
|
+
STDERR.puts "No Aspell found"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "#{File.dirname(__FILE__)}/../test_helper"
|
4
|
+
require 'benchmark'
|
5
|
+
require 'ruby-prof'
|
6
|
+
|
7
|
+
#def debugger; end
|
8
|
+
# require 'ruby-debug'
|
9
|
+
|
10
|
+
PROF = ENV['PROF']
|
11
|
+
TIMES = 50
|
12
|
+
|
13
|
+
$options = [{:query => 'seller'}]
|
14
|
+
|
15
|
+
#$search = Ultrasphinx::Search.new(*$options).run
|
16
|
+
#$sellers = Seller.find_all_by_id($search.results.select{|o| o.is_a? Seller}.map(&:id))
|
17
|
+
#$users = User.find_all_by_id($search.results.select{|o| o.is_a? User}.map(&:id))
|
18
|
+
#
|
19
|
+
## Mocha didn't work; don't know why
|
20
|
+
#class Riddle::Client
|
21
|
+
# def query(*args); $search.response; end
|
22
|
+
#end
|
23
|
+
#class Seller
|
24
|
+
# def self.find_all_by_id(*args); $sellers; end
|
25
|
+
#end
|
26
|
+
#class User
|
27
|
+
# def self.find_all_by_id(*args); $users; end
|
28
|
+
#end
|
29
|
+
|
30
|
+
Benchmark.bm(20) do |x|
|
31
|
+
x.report("simple") do
|
32
|
+
TIMES.times do
|
33
|
+
Ultrasphinx::Search.new(*$options).run
|
34
|
+
end
|
35
|
+
end
|
36
|
+
x.report("excerpt") do
|
37
|
+
RubyProf.start if PROF
|
38
|
+
TIMES.times do
|
39
|
+
Ultrasphinx::Search.new(*$options).excerpt
|
40
|
+
end
|
41
|
+
RubyProf::GraphPrinter.new(RubyProf.stop).print(STDOUT, 0) if PROF
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/test/test_helper.rb
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'test/unit'
|
4
4
|
require 'echoe'
|
5
|
-
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'multi_rails_init'
|
8
|
+
rescue LoadError
|
9
|
+
STDERR.puts "No multi_rails found"
|
10
|
+
end
|
6
11
|
|
7
12
|
if defined? ENV['MULTIRAILS_RAILS_VERSION']
|
8
13
|
ENV['RAILS_GEM_VERSION'] = ENV['MULTIRAILS_RAILS_VERSION']
|
data/test/unit/parser_test.rb
CHANGED
@@ -7,7 +7,7 @@ class ParserTest < Test::Unit::TestCase
|
|
7
7
|
@s = Ultrasphinx::Search.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def test_valid_queries
|
11
11
|
[
|
12
12
|
'artichokes',
|
13
13
|
'artichokes',
|
@@ -88,12 +88,31 @@ class ParserTest < Test::Unit::TestCase
|
|
88
88
|
'"traditional"',
|
89
89
|
|
90
90
|
'cuisine:"american (traditional"',
|
91
|
-
'@cuisine "american traditional"'
|
91
|
+
'@cuisine "american traditional"',
|
92
|
+
|
93
|
+
'title:cats OR user:john',
|
94
|
+
'@title cats | @user john',
|
95
|
+
|
96
|
+
'user:john OR title:cats',
|
97
|
+
'@title cats | @user john',
|
92
98
|
|
93
99
|
].in_groups_of(2).each do |query, result|
|
94
100
|
assert_equal result, @s.send(:parse, query)
|
95
101
|
end
|
96
102
|
end
|
103
|
+
|
104
|
+
def test_invalid_queries
|
105
|
+
[
|
106
|
+
"\"",
|
107
|
+
"(",
|
108
|
+
")",
|
109
|
+
" \" "
|
110
|
+
].each do |query|
|
111
|
+
assert_raises(Ultrasphinx::Search::Parser::Error) do
|
112
|
+
@s.send(:parse, query)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
97
116
|
|
98
117
|
end
|
99
118
|
|
data/ultrasphinx.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Ultrasphinx-1.
|
2
|
+
# Gem::Specification for Ultrasphinx-1.9
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = %q{ultrasphinx}
|
7
|
-
s.version = "1.
|
7
|
+
s.version = "1.9"
|
8
8
|
|
9
9
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = [""]
|
13
|
-
s.date = %q{2008-
|
13
|
+
s.date = %q{2008-03-08}
|
14
14
|
s.description = %q{Ruby on Rails configurator and client to the Sphinx fulltext search engine.}
|
15
15
|
s.email = %q{}
|
16
|
-
s.files = ["CHANGELOG", "DEPLOYMENT_NOTES", "examples/ap.multi", "examples/default.base", "init.rb", "lib/ultrasphinx/associations.rb", "lib/ultrasphinx/autoload.rb", "lib/ultrasphinx/configure.rb", "lib/ultrasphinx/core_extensions.rb", "lib/ultrasphinx/fields.rb", "lib/ultrasphinx/is_indexed.rb", "lib/ultrasphinx/postgresql/concat_ws.sql", "lib/ultrasphinx/postgresql/crc32.sql", "lib/ultrasphinx/postgresql/group_concat.sql", "lib/ultrasphinx/postgresql/hex_to_int.sql", "lib/ultrasphinx/postgresql/language.sql", "lib/ultrasphinx/postgresql/unix_timestamp.sql", "lib/ultrasphinx/search/internals.rb", "lib/ultrasphinx/search/parser.rb", "lib/ultrasphinx/search.rb", "lib/ultrasphinx/spell.rb", "lib/ultrasphinx/ultrasphinx.rb", "lib/ultrasphinx.rb", "LICENSE", "Manifest", "RAKE_TASKS", "README", "tasks/ultrasphinx.rake", "test/config/ultrasphinx/test.base", "test/integration/app/app/controllers/addresses_controller.rb", "test/integration/app/app/controllers/application.rb", "test/integration/app/app/controllers/sellers_controller.rb", "test/integration/app/app/controllers/states_controller.rb", "test/integration/app/app/controllers/users_controller.rb", "test/integration/app/app/helpers/addresses_helper.rb", "test/integration/app/app/helpers/application_helper.rb", "test/integration/app/app/helpers/sellers_helper.rb", "test/integration/app/app/helpers/states_helper.rb", "test/integration/app/app/helpers/users_helper.rb", "test/integration/app/app/models/geo/address.rb", "test/integration/app/app/models/geo/country.rb", "test/integration/app/app/models/geo/state.rb", "test/integration/app/app/models/person/user.rb", "test/integration/app/app/models/seller.rb", "test/integration/app/app/views/addresses/edit.html.erb", "test/integration/app/app/views/addresses/index.html.erb", "test/integration/app/app/views/addresses/new.html.erb", "test/integration/app/app/views/addresses/show.html.erb", "test/integration/app/app/views/layouts/addresses.html.erb", "test/integration/app/app/views/layouts/sellers.html.erb", "test/integration/app/app/views/layouts/states.html.erb", "test/integration/app/app/views/layouts/users.html.erb", "test/integration/app/app/views/sellers/edit.html.erb", "test/integration/app/app/views/sellers/index.html.erb", "test/integration/app/app/views/sellers/new.html.erb", "test/integration/app/app/views/sellers/show.html.erb", "test/integration/app/app/views/states/edit.html.erb", "test/integration/app/app/views/states/index.html.erb", "test/integration/app/app/views/states/new.html.erb", "test/integration/app/app/views/states/show.html.erb", "test/integration/app/app/views/users/edit.html.erb", "test/integration/app/app/views/users/index.html.erb", "test/integration/app/app/views/users/new.html.erb", "test/integration/app/app/views/users/show.html.erb", "test/integration/app/config/boot.rb", "test/integration/app/config/database.yml", "test/integration/app/config/environment.rb", "test/integration/app/config/environments/development.rb", "test/integration/app/config/environments/production.rb", "test/integration/app/config/environments/test.rb", "test/integration/app/config/locomotive.yml", "test/integration/app/config/routes.rb", "test/integration/app/config/ultrasphinx/default.base", "test/integration/app/config/ultrasphinx/development.conf.canonical", "test/integration/app/db/migrate/001_create_users.rb", "test/integration/app/db/migrate/002_create_sellers.rb", "test/integration/app/db/migrate/003_create_addresses.rb", "test/integration/app/db/migrate/004_create_states.rb", "test/integration/app/db/migrate/005_add_capitalization_to_seller.rb", "test/integration/app/db/migrate/006_add_deleted_to_user.rb", "test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb", "test/integration/app/db/migrate/008_add_mission_statement_to_seller.rb", "test/integration/app/db/migrate/009_create_countries.rb", "test/integration/app/doc/README_FOR_APP", "test/integration/app/public/404.html", "test/integration/app/public/500.html", "test/integration/app/public/dispatch.cgi", "test/integration/app/public/dispatch.fcgi", "test/integration/app/public/dispatch.rb", "test/integration/app/public/favicon.ico", "test/integration/app/public/images/rails.png", "test/integration/app/public/index.html", "test/integration/app/public/javascripts/application.js", "test/integration/app/public/javascripts/controls.js", "test/integration/app/public/javascripts/dragdrop.js", "test/integration/app/public/javascripts/effects.js", "test/integration/app/public/javascripts/prototype.js", "test/integration/app/public/robots.txt", "test/integration/app/public/stylesheets/scaffold.css", "test/integration/app/Rakefile", "test/integration/app/README", "test/integration/app/script/about", "test/integration/app/script/breakpointer", "test/integration/app/script/console", "test/integration/app/script/destroy", "test/integration/app/script/generate", "test/integration/app/script/performance/benchmarker", "test/integration/app/script/performance/profiler", "test/integration/app/script/plugin", "test/integration/app/script/process/inspector", "test/integration/app/script/process/reaper", "test/integration/app/script/process/spawner", "test/integration/app/script/runner", "test/integration/app/script/server", "test/integration/app/test/fixtures/addresses.yml", "test/integration/app/test/fixtures/countries.yml", "test/integration/app/test/fixtures/sellers.yml", "test/integration/app/test/fixtures/states.yml", "test/integration/app/test/fixtures/users.yml", "test/integration/app/test/functional/addresses_controller_test.rb", "test/integration/app/test/functional/sellers_controller_test.rb", "test/integration/app/test/functional/states_controller_test.rb", "test/integration/app/test/functional/users_controller_test.rb", "test/integration/app/test/test_helper.rb", "test/integration/app/test/unit/address_test.rb", "test/integration/app/test/unit/seller_test.rb", "test/integration/app/test/unit/state_test.rb", "test/integration/app/test/unit/user_test.rb", "test/integration/configure_test.rb", "test/integration/search_test.rb", "test/integration/server_test.rb", "test/integration/spell_test.rb", "test/setup.rb", "test/teardown.rb", "test/test_all.rb", "test/test_helper.rb", "test/ts.multi", "test/unit/parser_test.rb", "TODO", "vendor/riddle/lib/riddle/client/filter.rb", "vendor/riddle/lib/riddle/client/message.rb", "vendor/riddle/lib/riddle/client/response.rb", "vendor/riddle/lib/riddle/client.rb", "vendor/riddle/lib/riddle.rb", "vendor/riddle/MIT-LICENCE", "vendor/riddle/Rakefile", "vendor/riddle/README", "vendor/riddle/spec/fixtures/data/anchor.bin", "vendor/riddle/spec/fixtures/data/any.bin", "vendor/riddle/spec/fixtures/data/boolean.bin", "vendor/riddle/spec/fixtures/data/distinct.bin", "vendor/riddle/spec/fixtures/data/filter.bin", "vendor/riddle/spec/fixtures/data/filter_array.bin", "vendor/riddle/spec/fixtures/data/filter_array_exclude.bin", "vendor/riddle/spec/fixtures/data/filter_floats.bin", "vendor/riddle/spec/fixtures/data/filter_floats_exclude.bin", "vendor/riddle/spec/fixtures/data/filter_floats_range.bin", "vendor/riddle/spec/fixtures/data/filter_range.bin", "vendor/riddle/spec/fixtures/data/filter_range_exclude.bin", "vendor/riddle/spec/fixtures/data/group.bin", "vendor/riddle/spec/fixtures/data/index.bin", "vendor/riddle/spec/fixtures/data/phrase.bin", "vendor/riddle/spec/fixtures/data/simple.bin", "vendor/riddle/spec/fixtures/data/sort.bin", "vendor/riddle/spec/fixtures/data/update_simple.bin", "vendor/riddle/spec/fixtures/data/weights.bin", "vendor/riddle/spec/fixtures/sphinx/configuration.erb", "vendor/riddle/spec/fixtures/sql/conf.example.yml", "vendor/riddle/spec/fixtures/sql/data.sql", "vendor/riddle/spec/fixtures/sql/structure.sql", "vendor/riddle/spec/functional/excerpt_spec.rb", "vendor/riddle/spec/functional/search_spec.rb", "vendor/riddle/spec/functional/update_spec.rb", "vendor/riddle/spec/spec_helper.rb", "vendor/riddle/spec/sphinx_helper.rb", "vendor/riddle/spec/unit/client_spec.rb", "vendor/riddle/spec/unit/filter_spec.rb", "vendor/riddle/spec/unit/message_spec.rb", "vendor/riddle/spec/unit/response_spec.rb", "vendor/will_paginate/LICENSE", "ultrasphinx.gemspec"]
|
16
|
+
s.files = ["CHANGELOG", "DEPLOYMENT_NOTES", "examples/ap.multi", "examples/default.base", "init.rb", "lib/ultrasphinx/associations.rb", "lib/ultrasphinx/autoload.rb", "lib/ultrasphinx/configure.rb", "lib/ultrasphinx/core_extensions.rb", "lib/ultrasphinx/fields.rb", "lib/ultrasphinx/is_indexed.rb", "lib/ultrasphinx/postgresql/concat_ws.sql", "lib/ultrasphinx/postgresql/crc32.sql", "lib/ultrasphinx/postgresql/group_concat.sql", "lib/ultrasphinx/postgresql/hex_to_int.sql", "lib/ultrasphinx/postgresql/language.sql", "lib/ultrasphinx/postgresql/unix_timestamp.sql", "lib/ultrasphinx/search/internals.rb", "lib/ultrasphinx/search/parser.rb", "lib/ultrasphinx/search.rb", "lib/ultrasphinx/spell.rb", "lib/ultrasphinx/ultrasphinx.rb", "lib/ultrasphinx.rb", "LICENSE", "Manifest", "RAKE_TASKS", "README", "tasks/ultrasphinx.rake", "test/config/ultrasphinx/test.base", "test/integration/app/app/controllers/addresses_controller.rb", "test/integration/app/app/controllers/application.rb", "test/integration/app/app/controllers/sellers_controller.rb", "test/integration/app/app/controllers/states_controller.rb", "test/integration/app/app/controllers/users_controller.rb", "test/integration/app/app/helpers/addresses_helper.rb", "test/integration/app/app/helpers/application_helper.rb", "test/integration/app/app/helpers/sellers_helper.rb", "test/integration/app/app/helpers/states_helper.rb", "test/integration/app/app/helpers/users_helper.rb", "test/integration/app/app/models/geo/address.rb", "test/integration/app/app/models/geo/country.rb", "test/integration/app/app/models/geo/state.rb", "test/integration/app/app/models/person/user.rb", "test/integration/app/app/models/seller.rb", "test/integration/app/app/views/addresses/edit.html.erb", "test/integration/app/app/views/addresses/index.html.erb", "test/integration/app/app/views/addresses/new.html.erb", "test/integration/app/app/views/addresses/show.html.erb", "test/integration/app/app/views/layouts/addresses.html.erb", "test/integration/app/app/views/layouts/sellers.html.erb", "test/integration/app/app/views/layouts/states.html.erb", "test/integration/app/app/views/layouts/users.html.erb", "test/integration/app/app/views/sellers/edit.html.erb", "test/integration/app/app/views/sellers/index.html.erb", "test/integration/app/app/views/sellers/new.html.erb", "test/integration/app/app/views/sellers/show.html.erb", "test/integration/app/app/views/states/edit.html.erb", "test/integration/app/app/views/states/index.html.erb", "test/integration/app/app/views/states/new.html.erb", "test/integration/app/app/views/states/show.html.erb", "test/integration/app/app/views/users/edit.html.erb", "test/integration/app/app/views/users/index.html.erb", "test/integration/app/app/views/users/new.html.erb", "test/integration/app/app/views/users/show.html.erb", "test/integration/app/config/boot.rb", "test/integration/app/config/database.yml", "test/integration/app/config/environment.rb", "test/integration/app/config/environments/development.rb", "test/integration/app/config/environments/production.rb", "test/integration/app/config/environments/test.rb", "test/integration/app/config/locomotive.yml", "test/integration/app/config/routes.rb", "test/integration/app/config/ultrasphinx/default.base", "test/integration/app/config/ultrasphinx/development.conf", "test/integration/app/config/ultrasphinx/development.conf.canonical", "test/integration/app/db/migrate/001_create_users.rb", "test/integration/app/db/migrate/002_create_sellers.rb", "test/integration/app/db/migrate/003_create_addresses.rb", "test/integration/app/db/migrate/004_create_states.rb", "test/integration/app/db/migrate/005_add_capitalization_to_seller.rb", "test/integration/app/db/migrate/006_add_deleted_to_user.rb", "test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb", "test/integration/app/db/migrate/008_add_mission_statement_to_seller.rb", "test/integration/app/db/migrate/009_create_countries.rb", "test/integration/app/db/schema.rb", "test/integration/app/doc/README_FOR_APP", "test/integration/app/public/404.html", "test/integration/app/public/500.html", "test/integration/app/public/dispatch.cgi", "test/integration/app/public/dispatch.fcgi", "test/integration/app/public/dispatch.rb", "test/integration/app/public/favicon.ico", "test/integration/app/public/images/rails.png", "test/integration/app/public/index.html", "test/integration/app/public/javascripts/application.js", "test/integration/app/public/javascripts/controls.js", "test/integration/app/public/javascripts/dragdrop.js", "test/integration/app/public/javascripts/effects.js", "test/integration/app/public/javascripts/prototype.js", "test/integration/app/public/robots.txt", "test/integration/app/public/stylesheets/scaffold.css", "test/integration/app/Rakefile", "test/integration/app/README", "test/integration/app/script/about", "test/integration/app/script/breakpointer", "test/integration/app/script/console", "test/integration/app/script/destroy", "test/integration/app/script/generate", "test/integration/app/script/performance/benchmarker", "test/integration/app/script/performance/profiler", "test/integration/app/script/plugin", "test/integration/app/script/process/inspector", "test/integration/app/script/process/reaper", "test/integration/app/script/process/spawner", "test/integration/app/script/runner", "test/integration/app/script/server", "test/integration/app/test/fixtures/addresses.yml", "test/integration/app/test/fixtures/countries.yml", "test/integration/app/test/fixtures/sellers.yml", "test/integration/app/test/fixtures/states.yml", "test/integration/app/test/fixtures/users.yml", "test/integration/app/test/functional/addresses_controller_test.rb", "test/integration/app/test/functional/sellers_controller_test.rb", "test/integration/app/test/functional/states_controller_test.rb", "test/integration/app/test/functional/users_controller_test.rb", "test/integration/app/test/test_helper.rb", "test/integration/app/test/unit/address_test.rb", "test/integration/app/test/unit/country_test.rb", "test/integration/app/test/unit/seller_test.rb", "test/integration/app/test/unit/state_test.rb", "test/integration/app/test/unit/user_test.rb", "test/integration/configure_test.rb", "test/integration/delta_test.rb", "test/integration/search_test.rb", "test/integration/server_test.rb", "test/integration/spell_test.rb", "test/profile/benchmark.rb", "test/setup.rb", "test/teardown.rb", "test/test_all.rb", "test/test_helper.rb", "test/ts.multi", "test/unit/parser_test.rb", "TODO", "vendor/riddle/lib/riddle/client/filter.rb", "vendor/riddle/lib/riddle/client/message.rb", "vendor/riddle/lib/riddle/client/response.rb", "vendor/riddle/lib/riddle/client.rb", "vendor/riddle/lib/riddle.rb", "vendor/riddle/MIT-LICENCE", "vendor/riddle/Rakefile", "vendor/riddle/README", "vendor/riddle/spec/fixtures/data/anchor.bin", "vendor/riddle/spec/fixtures/data/any.bin", "vendor/riddle/spec/fixtures/data/boolean.bin", "vendor/riddle/spec/fixtures/data/distinct.bin", "vendor/riddle/spec/fixtures/data/field_weights.bin", "vendor/riddle/spec/fixtures/data/filter.bin", "vendor/riddle/spec/fixtures/data/filter_array.bin", "vendor/riddle/spec/fixtures/data/filter_array_exclude.bin", "vendor/riddle/spec/fixtures/data/filter_floats.bin", "vendor/riddle/spec/fixtures/data/filter_floats_exclude.bin", "vendor/riddle/spec/fixtures/data/filter_floats_range.bin", "vendor/riddle/spec/fixtures/data/filter_range.bin", "vendor/riddle/spec/fixtures/data/filter_range_exclude.bin", "vendor/riddle/spec/fixtures/data/group.bin", "vendor/riddle/spec/fixtures/data/index.bin", "vendor/riddle/spec/fixtures/data/index_weights.bin", "vendor/riddle/spec/fixtures/data/phrase.bin", "vendor/riddle/spec/fixtures/data/rank_mode.bin", "vendor/riddle/spec/fixtures/data/simple.bin", "vendor/riddle/spec/fixtures/data/sort.bin", "vendor/riddle/spec/fixtures/data/update_simple.bin", "vendor/riddle/spec/fixtures/data/weights.bin", "vendor/riddle/spec/fixtures/data_generator.php", "vendor/riddle/spec/fixtures/sphinx/configuration.erb", "vendor/riddle/spec/fixtures/sphinxapi.php", "vendor/riddle/spec/fixtures/sql/conf.example.yml", "vendor/riddle/spec/fixtures/sql/data.sql", "vendor/riddle/spec/fixtures/sql/structure.sql", "vendor/riddle/spec/functional/excerpt_spec.rb", "vendor/riddle/spec/functional/search_spec.rb", "vendor/riddle/spec/functional/update_spec.rb", "vendor/riddle/spec/spec_helper.rb", "vendor/riddle/spec/sphinx_helper.rb", "vendor/riddle/spec/unit/client_spec.rb", "vendor/riddle/spec/unit/filter_spec.rb", "vendor/riddle/spec/unit/message_spec.rb", "vendor/riddle/spec/unit/response_spec.rb", "vendor/will_paginate/LICENSE", "ultrasphinx.gemspec"]
|
17
17
|
s.has_rdoc = true
|
18
18
|
s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/}
|
19
19
|
s.require_paths = ["lib"]
|
data/vendor/riddle/README
CHANGED
@@ -8,13 +8,13 @@ opting for a more Ruby-like structure.
|
|
8
8
|
While it doesn't (yet) exist as a gem, you can obtain the sourcecode via subversion. If you
|
9
9
|
are after a specific release, use the tag as follows:
|
10
10
|
|
11
|
-
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-
|
11
|
+
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-r1112 riddle
|
12
12
|
|
13
13
|
Or for the most current, just use trunk:
|
14
14
|
|
15
15
|
svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/trunk riddle
|
16
16
|
|
17
|
-
Please note that at the time of writing, only 0.9.8r871
|
17
|
+
Please note that at the time of writing, only 0.9.8r871 through to 0.9.8r1112 are supported.
|
18
18
|
|
19
19
|
To get started, just instantiate a Client object:
|
20
20
|
|
data/vendor/riddle/lib/riddle.rb
CHANGED
@@ -57,7 +57,8 @@ module Riddle
|
|
57
57
|
RankModes = {
|
58
58
|
:proximity_bm25 => 0, # SPH_RANK_PROXIMITY_BM25
|
59
59
|
:bm25 => 1, # SPH_RANK_BM25
|
60
|
-
:none => 2
|
60
|
+
:none => 2, # SPH_RANK_NONE
|
61
|
+
:wordcount => 3 # SPH_RANK_WORDCOUNT
|
61
62
|
}
|
62
63
|
|
63
64
|
SortModes = {
|
@@ -65,7 +66,8 @@ module Riddle
|
|
65
66
|
:attr_desc => 1, # SPH_SORT_ATTR_DESC
|
66
67
|
:attr_asc => 2, # SPH_SORT_ATTR_ASC
|
67
68
|
:time_segments => 3, # SPH_SORT_TIME_SEGMENTS
|
68
|
-
:extended => 4
|
69
|
+
:extended => 4, # SPH_SORT_EXTENDED
|
70
|
+
:expr => 5 # SPH_SORT_EXPR
|
69
71
|
}
|
70
72
|
|
71
73
|
AttributeTypes = {
|
@@ -135,17 +137,22 @@ module Riddle
|
|
135
137
|
end
|
136
138
|
|
137
139
|
# Set the geo-anchor point - with the names of the attributes that contain
|
138
|
-
# the latitude and
|
140
|
+
# the latitude and longitude (in radians), and the reference position.
|
141
|
+
# Note that for geocoding to work properly, you must also set
|
142
|
+
# match_mode to :extended. To sort results by distance, you will
|
143
|
+
# need to set sort_mode to '@geodist asc' for example. Sphinx
|
144
|
+
# expects latitude and longitude to be returned from you SQL source
|
145
|
+
# in radians.
|
139
146
|
#
|
140
147
|
# Example:
|
141
|
-
# client.set_anchor('lat', -
|
148
|
+
# client.set_anchor('lat', -0.6591741, 'long', 2.530770)
|
142
149
|
#
|
143
150
|
def set_anchor(lat_attr, lat, long_attr, long)
|
144
151
|
@anchor = {
|
145
152
|
:latitude_attribute => lat_attr,
|
146
153
|
:latitude => lat,
|
147
|
-
:
|
148
|
-
:
|
154
|
+
:longitude_attribute => long_attr,
|
155
|
+
:longitude => long
|
149
156
|
}
|
150
157
|
end
|
151
158
|
|
@@ -273,7 +280,10 @@ module Riddle
|
|
273
280
|
self.run.first
|
274
281
|
end
|
275
282
|
|
276
|
-
#
|
283
|
+
# Build excerpts from search terms (the +words+) and the text of documents. Excerpts are bodies of text that have the +words+ highlighted.
|
284
|
+
# They may also be abbreviated to fit within a word limit.
|
285
|
+
#
|
286
|
+
# As part of the options hash, you will need to
|
277
287
|
# define:
|
278
288
|
# * :docs
|
279
289
|
# * :words
|
@@ -290,6 +300,31 @@ module Riddle
|
|
290
300
|
#
|
291
301
|
# The defaults differ from the official PHP client, as I've opted for
|
292
302
|
# semantic HTML markup.
|
303
|
+
#
|
304
|
+
# Example:
|
305
|
+
#
|
306
|
+
# client.excerpts(:docs => ["Pat Allan, Pat Cash"], :words => 'Pat', :index => 'pats')
|
307
|
+
# #=> ["<span class=\"match\">Pat</span> Allan, <span class=\"match\">Pat</span> Cash"]
|
308
|
+
#
|
309
|
+
# lorem_lipsum = "Lorem ipsum dolor..."
|
310
|
+
#
|
311
|
+
# client.excerpts(:docs => ["Pat Allan, #{lorem_lipsum} Pat Cash"], :words => 'Pat', :index => 'pats')
|
312
|
+
# #=> ["<span class=\"match\">Pat</span> Allan, Lorem ipsum dolor sit amet, consectetur adipisicing
|
313
|
+
# elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua … . Excepteur
|
314
|
+
# sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
315
|
+
# laborum. <span class=\"match\">Pat</span> Cash"]
|
316
|
+
#
|
317
|
+
# Workflow:
|
318
|
+
#
|
319
|
+
# Excerpt creation is completely isolated from searching the index. The nominated index is only used to
|
320
|
+
# discover encoding and charset information.
|
321
|
+
#
|
322
|
+
# Therefore, the workflow goes:
|
323
|
+
#
|
324
|
+
# 1. Do the sphinx query.
|
325
|
+
# 2. Fetch the documents found by sphinx from their repositories.
|
326
|
+
# 3. Pass the documents' text to +excerpts+ for marking up of matched terms.
|
327
|
+
#
|
293
328
|
def excerpts(options = {})
|
294
329
|
options[:index] ||= '*'
|
295
330
|
options[:before_match] ||= '<span class="match">'
|
@@ -444,8 +479,8 @@ module Riddle
|
|
444
479
|
else
|
445
480
|
message.append_int 1
|
446
481
|
message.append_string @anchor[:latitude_attribute]
|
447
|
-
message.append_string @anchor[:
|
448
|
-
message.append_floats @anchor[:latitude], @anchor[:
|
482
|
+
message.append_string @anchor[:longitude_attribute]
|
483
|
+
message.append_floats @anchor[:latitude], @anchor[:longitude]
|
449
484
|
end
|
450
485
|
|
451
486
|
# Per Index Weights
|
@@ -510,4 +545,4 @@ module Riddle
|
|
510
545
|
message.to_s
|
511
546
|
end
|
512
547
|
end
|
513
|
-
end
|
548
|
+
end
|