ultrasphinx 1.9 → 1.11
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +6 -0
- data/DEPLOYMENT_NOTES +3 -1
- data/Manifest +10 -2
- data/RAKE_TASKS +2 -1
- data/README +6 -6
- data/Rakefile +27 -0
- data/examples/default.base +7 -2
- data/init.rb +1 -0
- data/lib/ultrasphinx/autoload.rb +0 -1
- data/lib/ultrasphinx/configure.rb +64 -36
- data/lib/ultrasphinx/core_extensions.rb +17 -2
- data/lib/ultrasphinx/fields.rb +33 -13
- data/lib/ultrasphinx/is_indexed.rb +32 -14
- data/lib/ultrasphinx/postgresql/concat_ws.sql +3 -3
- data/lib/ultrasphinx/postgresql/crc32.sql +1 -1
- data/lib/ultrasphinx/postgresql/group_concat.sql +1 -3
- data/lib/ultrasphinx/postgresql/hex_to_int.sql +1 -1
- data/lib/ultrasphinx/postgresql/unix_timestamp.sql +1 -1
- data/lib/ultrasphinx/search.rb +56 -6
- data/lib/ultrasphinx/search/internals.rb +88 -23
- data/lib/ultrasphinx/search/parser.rb +16 -2
- data/lib/ultrasphinx/spell.rb +2 -1
- data/lib/ultrasphinx/ultrasphinx.rb +43 -49
- data/tasks/ultrasphinx.rake +56 -16
- data/test/config/ultrasphinx/test.base +7 -2
- data/test/integration/app/app/controllers/addresses_controller.rb +9 -9
- data/test/integration/app/app/controllers/states_controller.rb +9 -9
- data/test/integration/app/app/models/category.rb +5 -0
- data/test/integration/app/app/models/geo/address.rb +1 -1
- data/test/integration/app/app/models/seller.rb +3 -3
- data/test/integration/app/app/views/addresses/edit.html.erb +2 -2
- data/test/integration/app/app/views/addresses/index.html.erb +2 -2
- data/test/integration/app/app/views/addresses/new.html.erb +1 -1
- data/test/integration/app/app/views/states/edit.html.erb +2 -2
- data/test/integration/app/app/views/states/index.html.erb +2 -2
- data/test/integration/app/app/views/states/new.html.erb +1 -1
- data/test/integration/app/app/views/users/index.html.erb +3 -3
- data/test/integration/app/config/environment.rb +1 -0
- data/test/integration/app/config/ultrasphinx/default.base +2 -2
- data/test/integration/app/config/ultrasphinx/development.conf.canonical +74 -50
- data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +3 -3
- data/test/integration/app/db/migrate/010_create_categories.rb +14 -0
- data/test/integration/app/db/migrate/011_categories_sellers.rb +15 -0
- data/test/integration/app/public/dispatch.cgi +0 -0
- data/test/integration/app/public/dispatch.fcgi +0 -0
- data/test/integration/app/public/dispatch.rb +0 -0
- data/test/integration/app/script/about +0 -0
- data/test/integration/app/script/breakpointer +0 -0
- data/test/integration/app/script/console +0 -0
- data/test/integration/app/script/destroy +0 -0
- data/test/integration/app/script/generate +0 -0
- data/test/integration/app/script/performance/benchmarker +0 -0
- data/test/integration/app/script/performance/profiler +0 -0
- data/test/integration/app/script/plugin +0 -0
- data/test/integration/app/script/process/inspector +0 -0
- data/test/integration/app/script/process/reaper +0 -0
- data/test/integration/app/script/process/spawner +0 -0
- data/test/integration/app/script/runner +0 -0
- data/test/integration/app/script/server +0 -0
- data/test/integration/app/test/fixtures/addresses.yml +77 -6
- data/test/integration/app/test/fixtures/categories.yml +101 -0
- data/test/integration/app/test/fixtures/categories_sellers.yml +29 -0
- data/test/integration/app/test/functional/addresses_controller_test.rb +9 -4
- data/test/integration/app/test/functional/sellers_controller_test.rb +9 -2
- data/test/integration/app/test/functional/states_controller_test.rb +10 -4
- data/test/integration/app/test/functional/users_controller_test.rb +7 -2
- data/test/integration/app/test/unit/address_test.rb +1 -1
- data/test/integration/app/test/unit/category_test.rb +8 -0
- data/test/integration/app/test/unit/country_test.rb +1 -1
- data/test/integration/app/test/unit/state_test.rb +1 -1
- data/test/integration/app/test/unit/user_test.rb +1 -1
- data/test/integration/delta_test.rb +13 -0
- data/test/integration/search_test.rb +80 -8
- data/test/profile/benchmark.rb +0 -0
- data/test/setup.rb +25 -7
- data/test/teardown.rb +13 -0
- data/test/test_helper.rb +3 -3
- data/ultrasphinx.gemspec +22 -43
- data/vendor/riddle/README +18 -4
- data/vendor/riddle/Rakefile +1 -0
- data/vendor/riddle/lib/riddle.rb +11 -5
- data/vendor/riddle/lib/riddle/client.rb +65 -20
- data/vendor/riddle/lib/riddle/client/response.rb +10 -0
- 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/comment.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/keywords_with_hits.bin +0 -0
- data/vendor/riddle/spec/fixtures/data/keywords_without_hits.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/weights.bin +0 -0
- data/vendor/riddle/spec/fixtures/data_generator.php +15 -0
- data/vendor/riddle/spec/fixtures/sphinx/configuration.erb +4 -4
- data/vendor/riddle/spec/fixtures/sphinxapi.php +118 -7
- data/vendor/riddle/spec/functional/keywords_spec.rb +40 -0
- data/vendor/riddle/spec/spec_helper.rb +1 -0
- data/vendor/riddle/spec/unit/client_spec.rb +26 -0
- metadata +38 -11
- metadata.gz.sig +0 -0
- data/test/integration/app/config/ultrasphinx/development.conf +0 -319
- data/test/integration/app/db/schema.rb +0 -56
@@ -1,11 +1,11 @@
|
|
1
1
|
class AddLatAndLongToAddress < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
add_column :addresses, :lat, :float
|
4
|
-
add_column :addresses, :
|
3
|
+
add_column :addresses, :lat, :float # Postgres doesn't have :double
|
4
|
+
add_column :addresses, :lng, :float
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.down
|
8
8
|
remove_column :addresses, :lat
|
9
|
-
remove_column :addresses, :
|
9
|
+
remove_column :addresses, :lng
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateCategories < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "categories" do |t|
|
4
|
+
t.string "name", :default => "", :null => false
|
5
|
+
t.integer "parent_id"
|
6
|
+
t.integer "children_count"
|
7
|
+
t.string "permalink"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :categories
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CategoriesSellers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "categories_sellers", :id => false, :force => true do |t|
|
4
|
+
t.integer "category_id", :null => false
|
5
|
+
t.integer "seller_id", :null => false
|
6
|
+
end
|
7
|
+
|
8
|
+
add_index "categories_sellers", ["category_id"], :name => "index_categories_sellers_on_category_id"
|
9
|
+
add_index "categories_sellers", ["seller_id"], :name => "index_categories_sellers_on_seller_id"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table "categories_sellers"
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,13 +1,84 @@
|
|
1
|
-
|
1
|
+
# Waikiki AquariumAddress:
|
2
|
+
# 2777 Kalakaua Ave
|
3
|
+
# Honolulu, HI 96815
|
4
|
+
# (21.265915, -157.821256)
|
5
|
+
# 0.972 miles to Diamond Head State Park
|
6
|
+
# 10.147 miles to Aloha Stadium
|
7
|
+
# 10.880 miles to Kailua Beach Park
|
8
|
+
<% 1.upto(10) do |num| %>
|
2
9
|
<%="address#{num}:" %>
|
3
10
|
id: <%= num %>
|
4
11
|
user_id: <%= num %>
|
5
|
-
name: <%= "
|
6
|
-
line_1: "
|
12
|
+
name: <%= "Waikiki Aquarium #{num}" %>
|
13
|
+
line_1: "2777 Kalakaua Ave"
|
7
14
|
line_2: "Suite 122"
|
8
|
-
city: "
|
15
|
+
city: "Honolulu"
|
9
16
|
state_id: 15
|
10
|
-
province_region: "
|
11
|
-
zip_postal_code: "
|
17
|
+
province_region: "Honolulu County"
|
18
|
+
zip_postal_code: "96815"
|
12
19
|
country_id: 2
|
20
|
+
lat: <%= 21.265915 %>
|
21
|
+
lng: <%= -157.821256 %>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
# Diamond Head State Monument
|
25
|
+
# 4200 Diamond Head Rd
|
26
|
+
# Honolulu, HI 96816
|
27
|
+
# (21.2627, -157.80655)
|
28
|
+
# 10.563 miles to Kailua Beach Park
|
29
|
+
<% 11.upto(20) do |num| %>
|
30
|
+
<%="address#{num}:" %>
|
31
|
+
id: <%= num %>
|
32
|
+
user_id: <%= num %>
|
33
|
+
name: <%= "Diamond Head State Monument #{num}" %>
|
34
|
+
line_1: "4200 Diamond Head Rd"
|
35
|
+
line_2: "Suite 122"
|
36
|
+
city: "Honolulu"
|
37
|
+
state_id: 15
|
38
|
+
province_region: "Honolulu County"
|
39
|
+
zip_postal_code: "96816"
|
40
|
+
country_id: 2
|
41
|
+
lat: <%= 21.2627 %>
|
42
|
+
lng: <%= -157.80655 %>
|
43
|
+
<% end %>
|
44
|
+
|
45
|
+
# Aloha StadiumAddress:
|
46
|
+
# 99-500 Salt Lake Blvd
|
47
|
+
# Aiea, HI 96701
|
48
|
+
# (21.370824, -157.931578)
|
49
|
+
# 13.366 miles to Kailua Beach Park
|
50
|
+
<% 21.upto(30) do |num| %>
|
51
|
+
<%="address#{num}:" %>
|
52
|
+
id: <%= num %>
|
53
|
+
user_id: <%= num %>
|
54
|
+
name: <%= "Aloha Stadium #{num}" %>
|
55
|
+
line_1: "99-500 Salt Lake Blvd"
|
56
|
+
line_2: "Suite 122"
|
57
|
+
city: "Aiea"
|
58
|
+
state_id: 15
|
59
|
+
province_region: "Honolulu County"
|
60
|
+
zip_postal_code: "96701"
|
61
|
+
country_id: 2
|
62
|
+
lat: <%= 21.370824 %>
|
63
|
+
lng: <%= -157.80655 %>
|
64
|
+
<% end %>
|
65
|
+
|
66
|
+
# Kailua Beach ParkAddress:
|
67
|
+
# 450 Kawailoa Road
|
68
|
+
# Honolulu, HI 96734
|
69
|
+
# (21.39567059288111, -157.72552013397217)
|
70
|
+
<% 31.upto(40) do |num| %>
|
71
|
+
<%="address#{num}:" %>
|
72
|
+
id: <%= num %>
|
73
|
+
user_id: <%= num %>
|
74
|
+
name: <%= "Kailua Beach Park #{num}" %>
|
75
|
+
line_1: "450 Kawailoa Road"
|
76
|
+
line_2: "Suite 122"
|
77
|
+
city: "Honolulu"
|
78
|
+
state_id: 15
|
79
|
+
province_region: "Honolulu County"
|
80
|
+
zip_postal_code: "96734"
|
81
|
+
country_id: 2
|
82
|
+
lat: <%= 21.39567059288111 %>
|
83
|
+
lng: <%= -157.72552013397217 %>
|
13
84
|
<% end %>
|
@@ -0,0 +1,101 @@
|
|
1
|
+
---
|
2
|
+
categories_001:
|
3
|
+
name: Category 1
|
4
|
+
id: "1"
|
5
|
+
children_count: "3"
|
6
|
+
parent_id: "0"
|
7
|
+
categories_0002:
|
8
|
+
name: Category 2
|
9
|
+
id: "2"
|
10
|
+
children_count: "3"
|
11
|
+
parent_id: "1"
|
12
|
+
categories_0003:
|
13
|
+
name: Category 3
|
14
|
+
id: "3"
|
15
|
+
children_count: "3"
|
16
|
+
parent_id: "1"
|
17
|
+
categories_0004:
|
18
|
+
name: Category 4
|
19
|
+
id: "4"
|
20
|
+
children_count: "0"
|
21
|
+
parent_id: "1"
|
22
|
+
categories_0005:
|
23
|
+
name: Category 5
|
24
|
+
id: "5"
|
25
|
+
children_count: "0"
|
26
|
+
parent_id: "2"
|
27
|
+
categories_0006:
|
28
|
+
name: Category 6
|
29
|
+
id: "6"
|
30
|
+
children_count: "0"
|
31
|
+
parent_id: "2"
|
32
|
+
categories_0007:
|
33
|
+
name: Category 7
|
34
|
+
id: "7"
|
35
|
+
children_count: "0"
|
36
|
+
parent_id: "2"
|
37
|
+
categories_0008:
|
38
|
+
name: Category 8
|
39
|
+
id: "8"
|
40
|
+
children_count: "0"
|
41
|
+
parent_id: "3"
|
42
|
+
categories_0009:
|
43
|
+
name: Category 9
|
44
|
+
id: "9"
|
45
|
+
children_count: "0"
|
46
|
+
parent_id: "3"
|
47
|
+
categories_0010:
|
48
|
+
name: Category 10
|
49
|
+
id: "10"
|
50
|
+
children_count: "0"
|
51
|
+
parent_id: "3"
|
52
|
+
categories_0011:
|
53
|
+
name: Category 11
|
54
|
+
id: "11"
|
55
|
+
children_count: "3"
|
56
|
+
parent_id: "0"
|
57
|
+
categories_0012:
|
58
|
+
name: Category 12
|
59
|
+
id: "12"
|
60
|
+
children_count: "3"
|
61
|
+
parent_id: "1"
|
62
|
+
categories_0013:
|
63
|
+
name: Category 13
|
64
|
+
id: "13"
|
65
|
+
children_count: "3"
|
66
|
+
parent_id: "1"
|
67
|
+
categories_0014:
|
68
|
+
name: Category 14
|
69
|
+
id: "14"
|
70
|
+
children_count: "0"
|
71
|
+
parent_id: "1"
|
72
|
+
categories_0015:
|
73
|
+
name: Category 15
|
74
|
+
id: "15"
|
75
|
+
children_count: "0"
|
76
|
+
parent_id: "2"
|
77
|
+
categories_0016:
|
78
|
+
name: Category 16
|
79
|
+
id: "16"
|
80
|
+
children_count: "0"
|
81
|
+
parent_id: "2"
|
82
|
+
categories_0017:
|
83
|
+
name: Category 17
|
84
|
+
id: "17"
|
85
|
+
children_count: "0"
|
86
|
+
parent_id: "2"
|
87
|
+
categories_0018:
|
88
|
+
name: Category 18
|
89
|
+
id: "18"
|
90
|
+
children_count: "0"
|
91
|
+
parent_id: "3"
|
92
|
+
categories_0019:
|
93
|
+
name: Category 19
|
94
|
+
id: "19"
|
95
|
+
children_count: "0"
|
96
|
+
parent_id: "3"
|
97
|
+
categories_0020:
|
98
|
+
name: Category 20
|
99
|
+
id: "20"
|
100
|
+
children_count: "0"
|
101
|
+
parent_id: "3"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
categories_sellers_a1:
|
2
|
+
seller_id: 1
|
3
|
+
category_id: 1 # Category 1
|
4
|
+
categories_sellers_b1:
|
5
|
+
seller_id: 1
|
6
|
+
category_id: 2 # Category 2
|
7
|
+
categories_sellers_extra1:
|
8
|
+
seller_id: 1
|
9
|
+
category_id: 3 # A category from the remaining categories
|
10
|
+
categories_sellers_a2:
|
11
|
+
seller_id: 2
|
12
|
+
category_id: 1 # Category 1
|
13
|
+
categories_sellers_b2:
|
14
|
+
seller_id: 2
|
15
|
+
category_id: 2 # Category 2
|
16
|
+
categories_sellers_extra2:
|
17
|
+
seller_id: 2
|
18
|
+
category_id: 3 # A category from the remaining categories
|
19
|
+
<% 3.upto(20) do |num| %>
|
20
|
+
<%="categories_sellers_a#{num}:" %>
|
21
|
+
seller_id: <%= num %>
|
22
|
+
category_id: 1 # Category 1
|
23
|
+
<%="categories_sellers_b#{num}:" %>
|
24
|
+
seller_id: <%= num %>
|
25
|
+
category_id: 2 # Category 2
|
26
|
+
<%="categories_sellers_extra#{num}:" %>
|
27
|
+
seller_id: <%= num %>
|
28
|
+
category_id: <%= num %> # A category from the remaining categories
|
29
|
+
<% end %>
|
@@ -25,8 +25,8 @@ class AddressesControllerTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_create_address
|
28
|
-
assert_difference('Address.count') do
|
29
|
-
post :create, :address => { }
|
28
|
+
assert_difference('Geo::Address.count') do
|
29
|
+
post :create, :address => { :user_id => 1, :state_id => 1, :country_id => 1 }
|
30
30
|
end
|
31
31
|
|
32
32
|
assert_redirected_to address_path(assigns(:address))
|
@@ -48,10 +48,15 @@ class AddressesControllerTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_destroy_address
|
51
|
-
|
52
|
-
|
51
|
+
new_address = Geo::Address.new(:user_id => 1, :name => 'test', :city => 'test', :state_id => 15, :country_id => 2)
|
52
|
+
|
53
|
+
assert_difference('Geo::Address.count', +1) do
|
54
|
+
new_address.save
|
53
55
|
end
|
54
56
|
|
57
|
+
assert_difference('Geo::Address.count', -1) do
|
58
|
+
delete :destroy, :id => new_address.id
|
59
|
+
end
|
55
60
|
assert_redirected_to addresses_path
|
56
61
|
end
|
57
62
|
end
|
@@ -26,7 +26,7 @@ class SellersControllerTest < Test::Unit::TestCase
|
|
26
26
|
|
27
27
|
def test_should_create_seller
|
28
28
|
assert_difference('Seller.count') do
|
29
|
-
post :create, :seller => { }
|
29
|
+
post :create, :seller => { :user_id => 1 }
|
30
30
|
end
|
31
31
|
|
32
32
|
assert_redirected_to seller_path(assigns(:seller))
|
@@ -48,8 +48,15 @@ class SellersControllerTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_destroy_seller
|
51
|
+
new_user = User.create(:login => 'test', :email => 'test@test.com')
|
52
|
+
new_seller = Seller.new(:user_id => new_user.id, :company_name => 'test')
|
53
|
+
|
54
|
+
assert_difference('Seller.count', +1) do
|
55
|
+
new_seller.save
|
56
|
+
end
|
57
|
+
|
51
58
|
assert_difference('Seller.count', -1) do
|
52
|
-
delete :destroy, :id =>
|
59
|
+
delete :destroy, :id => new_seller.id
|
53
60
|
end
|
54
61
|
|
55
62
|
assert_redirected_to sellers_path
|
@@ -25,8 +25,8 @@ class StatesControllerTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_should_create_state
|
28
|
-
assert_difference('State.count') do
|
29
|
-
post :create, :state => { }
|
28
|
+
assert_difference('Geo::State.count') do
|
29
|
+
post :create, :state => { :name => 'test', :abbreviation => 'te' }
|
30
30
|
end
|
31
31
|
|
32
32
|
assert_redirected_to state_path(assigns(:state))
|
@@ -48,10 +48,16 @@ class StatesControllerTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_destroy_state
|
51
|
-
|
52
|
-
|
51
|
+
new_state = Geo::State.new(:name => 'test', :abbreviation => 'te')
|
52
|
+
|
53
|
+
assert_difference('Geo::State.count', +1) do
|
54
|
+
new_state.save
|
53
55
|
end
|
54
56
|
|
57
|
+
assert_difference('Geo::State.count', -1) do
|
58
|
+
delete :destroy, :id => new_state.id
|
59
|
+
end
|
60
|
+
|
55
61
|
assert_redirected_to states_path
|
56
62
|
end
|
57
63
|
end
|
@@ -48,10 +48,15 @@ class UsersControllerTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_destroy_user
|
51
|
-
|
52
|
-
|
51
|
+
new_user = User.new(:login => 'test', :email => 'test@test.com')
|
52
|
+
|
53
|
+
assert_difference('User.count', +1) do
|
54
|
+
new_user.save
|
53
55
|
end
|
54
56
|
|
57
|
+
assert_difference('User.count', -1) do
|
58
|
+
delete :destroy, :id => new_user.id
|
59
|
+
end
|
55
60
|
assert_redirected_to users_path
|
56
61
|
end
|
57
62
|
end
|