ultrasphinx 1.9 → 1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +6 -0
  3. data/DEPLOYMENT_NOTES +3 -1
  4. data/Manifest +10 -2
  5. data/RAKE_TASKS +2 -1
  6. data/README +6 -6
  7. data/Rakefile +27 -0
  8. data/examples/default.base +7 -2
  9. data/init.rb +1 -0
  10. data/lib/ultrasphinx/autoload.rb +0 -1
  11. data/lib/ultrasphinx/configure.rb +64 -36
  12. data/lib/ultrasphinx/core_extensions.rb +17 -2
  13. data/lib/ultrasphinx/fields.rb +33 -13
  14. data/lib/ultrasphinx/is_indexed.rb +32 -14
  15. data/lib/ultrasphinx/postgresql/concat_ws.sql +3 -3
  16. data/lib/ultrasphinx/postgresql/crc32.sql +1 -1
  17. data/lib/ultrasphinx/postgresql/group_concat.sql +1 -3
  18. data/lib/ultrasphinx/postgresql/hex_to_int.sql +1 -1
  19. data/lib/ultrasphinx/postgresql/unix_timestamp.sql +1 -1
  20. data/lib/ultrasphinx/search.rb +56 -6
  21. data/lib/ultrasphinx/search/internals.rb +88 -23
  22. data/lib/ultrasphinx/search/parser.rb +16 -2
  23. data/lib/ultrasphinx/spell.rb +2 -1
  24. data/lib/ultrasphinx/ultrasphinx.rb +43 -49
  25. data/tasks/ultrasphinx.rake +56 -16
  26. data/test/config/ultrasphinx/test.base +7 -2
  27. data/test/integration/app/app/controllers/addresses_controller.rb +9 -9
  28. data/test/integration/app/app/controllers/states_controller.rb +9 -9
  29. data/test/integration/app/app/models/category.rb +5 -0
  30. data/test/integration/app/app/models/geo/address.rb +1 -1
  31. data/test/integration/app/app/models/seller.rb +3 -3
  32. data/test/integration/app/app/views/addresses/edit.html.erb +2 -2
  33. data/test/integration/app/app/views/addresses/index.html.erb +2 -2
  34. data/test/integration/app/app/views/addresses/new.html.erb +1 -1
  35. data/test/integration/app/app/views/states/edit.html.erb +2 -2
  36. data/test/integration/app/app/views/states/index.html.erb +2 -2
  37. data/test/integration/app/app/views/states/new.html.erb +1 -1
  38. data/test/integration/app/app/views/users/index.html.erb +3 -3
  39. data/test/integration/app/config/environment.rb +1 -0
  40. data/test/integration/app/config/ultrasphinx/default.base +2 -2
  41. data/test/integration/app/config/ultrasphinx/development.conf.canonical +74 -50
  42. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +3 -3
  43. data/test/integration/app/db/migrate/010_create_categories.rb +14 -0
  44. data/test/integration/app/db/migrate/011_categories_sellers.rb +15 -0
  45. data/test/integration/app/public/dispatch.cgi +0 -0
  46. data/test/integration/app/public/dispatch.fcgi +0 -0
  47. data/test/integration/app/public/dispatch.rb +0 -0
  48. data/test/integration/app/script/about +0 -0
  49. data/test/integration/app/script/breakpointer +0 -0
  50. data/test/integration/app/script/console +0 -0
  51. data/test/integration/app/script/destroy +0 -0
  52. data/test/integration/app/script/generate +0 -0
  53. data/test/integration/app/script/performance/benchmarker +0 -0
  54. data/test/integration/app/script/performance/profiler +0 -0
  55. data/test/integration/app/script/plugin +0 -0
  56. data/test/integration/app/script/process/inspector +0 -0
  57. data/test/integration/app/script/process/reaper +0 -0
  58. data/test/integration/app/script/process/spawner +0 -0
  59. data/test/integration/app/script/runner +0 -0
  60. data/test/integration/app/script/server +0 -0
  61. data/test/integration/app/test/fixtures/addresses.yml +77 -6
  62. data/test/integration/app/test/fixtures/categories.yml +101 -0
  63. data/test/integration/app/test/fixtures/categories_sellers.yml +29 -0
  64. data/test/integration/app/test/functional/addresses_controller_test.rb +9 -4
  65. data/test/integration/app/test/functional/sellers_controller_test.rb +9 -2
  66. data/test/integration/app/test/functional/states_controller_test.rb +10 -4
  67. data/test/integration/app/test/functional/users_controller_test.rb +7 -2
  68. data/test/integration/app/test/unit/address_test.rb +1 -1
  69. data/test/integration/app/test/unit/category_test.rb +8 -0
  70. data/test/integration/app/test/unit/country_test.rb +1 -1
  71. data/test/integration/app/test/unit/state_test.rb +1 -1
  72. data/test/integration/app/test/unit/user_test.rb +1 -1
  73. data/test/integration/delta_test.rb +13 -0
  74. data/test/integration/search_test.rb +80 -8
  75. data/test/profile/benchmark.rb +0 -0
  76. data/test/setup.rb +25 -7
  77. data/test/teardown.rb +13 -0
  78. data/test/test_helper.rb +3 -3
  79. data/ultrasphinx.gemspec +22 -43
  80. data/vendor/riddle/README +18 -4
  81. data/vendor/riddle/Rakefile +1 -0
  82. data/vendor/riddle/lib/riddle.rb +11 -5
  83. data/vendor/riddle/lib/riddle/client.rb +65 -20
  84. data/vendor/riddle/lib/riddle/client/response.rb +10 -0
  85. data/vendor/riddle/spec/fixtures/data/anchor.bin +0 -0
  86. data/vendor/riddle/spec/fixtures/data/any.bin +0 -0
  87. data/vendor/riddle/spec/fixtures/data/boolean.bin +0 -0
  88. data/vendor/riddle/spec/fixtures/data/comment.bin +0 -0
  89. data/vendor/riddle/spec/fixtures/data/distinct.bin +0 -0
  90. data/vendor/riddle/spec/fixtures/data/field_weights.bin +0 -0
  91. data/vendor/riddle/spec/fixtures/data/filter.bin +0 -0
  92. data/vendor/riddle/spec/fixtures/data/group.bin +0 -0
  93. data/vendor/riddle/spec/fixtures/data/index.bin +0 -0
  94. data/vendor/riddle/spec/fixtures/data/index_weights.bin +0 -0
  95. data/vendor/riddle/spec/fixtures/data/keywords_with_hits.bin +0 -0
  96. data/vendor/riddle/spec/fixtures/data/keywords_without_hits.bin +0 -0
  97. data/vendor/riddle/spec/fixtures/data/phrase.bin +0 -0
  98. data/vendor/riddle/spec/fixtures/data/rank_mode.bin +0 -0
  99. data/vendor/riddle/spec/fixtures/data/simple.bin +0 -0
  100. data/vendor/riddle/spec/fixtures/data/sort.bin +0 -0
  101. data/vendor/riddle/spec/fixtures/data/weights.bin +0 -0
  102. data/vendor/riddle/spec/fixtures/data_generator.php +15 -0
  103. data/vendor/riddle/spec/fixtures/sphinx/configuration.erb +4 -4
  104. data/vendor/riddle/spec/fixtures/sphinxapi.php +118 -7
  105. data/vendor/riddle/spec/functional/keywords_spec.rb +40 -0
  106. data/vendor/riddle/spec/spec_helper.rb +1 -0
  107. data/vendor/riddle/spec/unit/client_spec.rb +26 -0
  108. metadata +38 -11
  109. metadata.gz.sig +0 -0
  110. data/test/integration/app/config/ultrasphinx/development.conf +0 -319
  111. data/test/integration/app/db/schema.rb +0 -56
@@ -36,4 +36,17 @@ class DeltaTest < Test::Unit::TestCase
36
36
 
37
37
  assert_equal @count, S.new.total_entries
38
38
  end
39
+
40
+ def test_merge
41
+ Dir.chdir "#{HERE}/integration/app" do
42
+ Echoe.silence do
43
+ system("rake ultrasphinx:daemon:start")
44
+ end
45
+
46
+ output = `rake ultrasphinx:index:merge 2>&1`
47
+ assert_match /merged 0.1 Kwords/, output
48
+ assert_match /Index rotated ok/, output
49
+ end
50
+ end
51
+
39
52
  end
@@ -11,7 +11,7 @@ class SearchTest < Test::Unit::TestCase
11
11
  assert_nothing_raised do
12
12
  @s = S.new(:query => 'seller').run
13
13
  end
14
- assert_equal 20, @s.results.size
14
+ assert_equal 20, @s.size
15
15
  end
16
16
 
17
17
  def test_with_subtotals_option
@@ -34,6 +34,7 @@ class SearchTest < Test::Unit::TestCase
34
34
  end
35
35
 
36
36
  def test_ignore_missing_records_option
37
+ S.client_options['distance'] = false # must disable geodistance or line 57 will bomb
37
38
  @s = S.new(:per_page => 1).run
38
39
  @record = @s.first
39
40
  assert_equal 1, @s.size
@@ -50,9 +51,8 @@ class SearchTest < Test::Unit::TestCase
50
51
  end
51
52
  assert_equal 0, @s.size
52
53
  assert_equal 1, @s.per_page
53
-
54
54
  S.client_options['ignore_missing_records'] = false
55
-
55
+
56
56
  # Re-insert the record... ugh
57
57
  @new_record = @record.class.new(@record.attributes)
58
58
  @new_record.id = @record.id
@@ -198,6 +198,17 @@ class SearchTest < Test::Unit::TestCase
198
198
  S.new(:class_names => 'Seller', :filters => {'company_name' => 'seller17'}).run.size
199
199
  )
200
200
  end
201
+
202
+ def test_exclusion_filter
203
+ assert_equal(
204
+ Seller.count(:conditions => 'user_id = 17'),
205
+ S.new(:class_names => 'Seller', :filters => { 'user_id' => { 'value' => 17, 'exclude' => false } }).run.size
206
+ )
207
+ assert_equal(
208
+ Seller.count(:conditions => 'user_id != 17'),
209
+ S.new(:class_names => 'Seller', :filters => { 'user_id' => { 'value' => 17, 'exclude' => true } }).run.size
210
+ )
211
+ end
201
212
 
202
213
  def test_invalid_filter
203
214
  assert_raises(Ultrasphinx::UsageError) do
@@ -227,7 +238,7 @@ class SearchTest < Test::Unit::TestCase
227
238
 
228
239
  def test_unconfigured_sortable_name
229
240
  assert_raises(Ultrasphinx::UsageError) do
230
- S.new(:class_names => 'Seller', :sort_by => 'company_name', :sort_mode => 'ascending', :per_page => 5).run
241
+ S.new(:class_names => 'User', :sort_by => 'company', :sort_mode => 'ascending', :per_page => 5).run
231
242
  end
232
243
  end
233
244
 
@@ -253,7 +264,7 @@ class SearchTest < Test::Unit::TestCase
253
264
  end
254
265
 
255
266
  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
267
+ # There are 40 users, but only 20 sellers. So you get 20 facets + 1 nil with 20 items
257
268
  @s = Ultrasphinx::Search.new(:class_names => 'User', :facets => ['company']).run
258
269
  assert_equal(
259
270
  (Seller.count + 1),
@@ -262,8 +273,9 @@ class SearchTest < Test::Unit::TestCase
262
273
  end
263
274
 
264
275
  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
276
+ # XXX there are 40 users but only 20 sellers, but the replace function from User deletes
277
+ # User #6 and 16 (why? Hash collision?). There is also a nil facet that gets added for a
278
+ # total of 19 objects
267
279
  @s = Ultrasphinx::Search.new(:class_names => 'User', :facets => ['company_two']).run
268
280
  assert_equal(
269
281
  (Seller.count - 1),
@@ -317,4 +329,64 @@ class SearchTest < Test::Unit::TestCase
317
329
  assert_match /strong/, @excerpted_item.name
318
330
  end
319
331
 
320
- end
332
+ def test_distance_ascending
333
+ # (21.289453, -157.842783) is Ala Moana Shopping Center, 1450 Ala Moana Blvd, Honolulu HI 96814
334
+ @s = Ultrasphinx::Search.new(:class_names => 'Geo::Address',
335
+ :query => 'Honolulu',
336
+ :per_page => 40,
337
+ :sort_mode => 'extended',
338
+ :sort_by => 'distance',
339
+ :location => {
340
+ :lat => 21.289453,
341
+ :long => -157.842783
342
+ })
343
+ @s.run
344
+ # This should return all items in the database, sorted in increasing distance
345
+ assert_equal 40, @s.size
346
+ assert_match /Waikiki Aquarium/, @s.first.name
347
+ assert_match /Waikiki Aquarium/, @s[1].name
348
+ assert_in_delta 3439, @s.first.distance, 10
349
+ end
350
+
351
+ def test_distance_filter
352
+ # (21.289453, -157.842783) is Ala Moana Shopping Center, 1450 Ala Moana Blvd, Honolulu HI 96814
353
+ @s = Ultrasphinx::Search.new(:class_names => 'Geo::Address',
354
+ :query => 'Honolulu',
355
+ :per_page => 40,
356
+ :sort_mode => 'extended',
357
+ :sort_by => 'distance',
358
+ :filters => {'distance' => 0..5000},
359
+ :location => {
360
+ :lat => 21.289453,
361
+ :long => -157.842783
362
+ })
363
+ @s.run
364
+
365
+ @s.each do |obj|
366
+ # This should return only those items within 5000 meters of Ala Moana, which
367
+ # is only Waikiki Aquarium and Diamond Head.
368
+ assert_match /Waikiki Aquarium|Diamond Head/, obj.name
369
+ end
370
+
371
+ assert_in_delta 3439, @s.first.distance, 10 # Closest item should be Waikiki at 3439 meters
372
+ end
373
+
374
+ def test_distance_decending
375
+ # (21.289453, -157.842783) is Ala Moana Shopping Center, 1450 Ala Moana Blvd, Honolulu HI 96814
376
+ @s = Ultrasphinx::Search.new(:class_names => 'Geo::Address',
377
+ :query => 'Honolulu',
378
+ :per_page => 40,
379
+ :sort_mode => 'extended',
380
+ :sort_by => 'distance desc',
381
+ :location => {
382
+ :lat => 21.289453,
383
+ :long => -157.842783
384
+ })
385
+ @s.run
386
+
387
+ # Ids should come back in reverse order because the fixtures have the farther locations later in the file
388
+ assert_equal 40, @s.size
389
+ assert_match /Kailua Beach Park/, @s.first.name
390
+ assert_in_delta 16940, @s.first.distance, 40
391
+ end
392
+ end
File without changes
@@ -2,15 +2,33 @@
2
2
  # Setup integration system for the integration suite
3
3
 
4
4
  Dir.chdir "#{File.dirname(__FILE__)}/integration/app/" do
5
- system("killall searchd")
6
- system("rm -rf /tmp/sphinx")
5
+
6
+ pid_file = '/tmp/sphinx/searchd.pid'
7
+ if File.exist? pid_file
8
+ pid = File.read(pid_file).to_i
9
+ system("kill #{pid}"); sleep(2); system("kill -9 #{pid}")
10
+ end
11
+
12
+ system("rm -rf /tmp/sphinx")
7
13
  system("rm -rf config/ultrasphinx/development.conf")
14
+
8
15
  Dir.chdir "vendor/plugins" do
9
- system("rm ultrasphinx; ln -s ../../../../../ ultrasphinx")
16
+ system("rm ultrasphinx")
17
+ system("ln -s ../../../../../ ultrasphinx")
10
18
  end
11
- system("rake db:create")
12
- system("rake db:migrate db:fixtures:load")
13
- system("rake us:boot")
19
+
20
+ if ENV['DB'] == 'postgresql'
21
+ # http://dev.rubyonrails.org/ticket/10559
22
+ system("echo 'DROP DATABASE ultrasphinx_development;' | psql template1")
23
+ else
24
+ system("rake db:drop --trace")
25
+ end
26
+
27
+ system("rake db:create --trace")
28
+ system("script/generate ultrasphinx_migration --svn") if ENV['DB'] == 'postgresql'
29
+ system("rake db:migrate db:fixtures:load --trace")
30
+
31
+ system("rake us:boot --trace")
14
32
  system("rm /tmp/ultrasphinx-stopwords.txt")
15
- system("rake ultrasphinx:spelling:build")
33
+ system("rake ultrasphinx:spelling:build --trace")
16
34
  end
@@ -0,0 +1,13 @@
1
+
2
+ # Tear down integration system for the integration suite
3
+
4
+ Dir.chdir "#{File.dirname(__FILE__)}/integration/app/" do
5
+ # Remove the symlink created by the setup method, for people with tools
6
+ # that can't handle recursive directories (Textmate).
7
+ system("rm vendor/plugins/ultrasphinx") unless ENV['USER'] == 'eweaver'
8
+
9
+ # Remove the generated Postgres migration, if it exists
10
+ Dir["db/migrate/*_install_ultrasphinx_stored_procedures.rb"].each do |file|
11
+ system("svn del --force #{file}")
12
+ end
13
+ end
@@ -21,6 +21,6 @@ end
21
21
 
22
22
  require 'integration/app/config/environment'
23
23
 
24
- Dir.chdir "#{HERE}/integration/app" do
25
- system("rake us:start")
26
- end
24
+ #Dir.chdir "#{HERE}/integration/app" do
25
+ # system("rake us:start")
26
+ #end
@@ -1,57 +1,36 @@
1
-
2
- # Gem::Specification for Ultrasphinx-1.9
3
- # Originally generated by Echoe
1
+ # -*- encoding: utf-8 -*-
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = %q{ultrasphinx}
7
- s.version = "1.9"
8
-
9
- s.specification_version = 2 if s.respond_to? :specification_version=
5
+ s.version = "1.11"
10
6
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
12
8
  s.authors = [""]
13
- s.date = %q{2008-03-08}
9
+ s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
+ s.date = %q{2009-11-18}
14
11
  s.description = %q{Ruby on Rails configurator and client to the Sphinx fulltext search engine.}
15
12
  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", "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
- s.has_rdoc = true
13
+ s.extra_rdoc_files = ["CHANGELOG", "DEPLOYMENT_NOTES", "lib/ultrasphinx/is_indexed.rb", "lib/ultrasphinx/search.rb", "lib/ultrasphinx/spell.rb", "lib/ultrasphinx/ultrasphinx.rb", "lib/ultrasphinx.rb", "LICENSE", "RAKE_TASKS", "README", "TODO"]
14
+ 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/category.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/db/migrate/010_create_categories.rb", "test/integration/app/db/migrate/011_categories_sellers.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/categories.yml", "test/integration/app/test/fixtures/categories_sellers.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/category_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/comment.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/keywords_with_hits.bin", "vendor/riddle/spec/fixtures/data/keywords_without_hits.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/keywords_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", "Rakefile"]
18
15
  s.homepage = %q{http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ultrasphinx", "--main", "README"]
19
17
  s.require_paths = ["lib"]
20
18
  s.rubyforge_project = %q{fauna}
21
- s.rubygems_version = %q{1.0.1}
19
+ s.rubygems_version = %q{1.3.5}
20
+ s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
22
21
  s.summary = %q{Ruby on Rails configurator and client to the Sphinx fulltext search engine.}
23
22
  s.test_files = ["test/test_all.rb"]
24
23
 
25
- s.add_dependency(%q<chronic>, [">= 0"])
26
- end
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
27
 
28
-
29
- # # Original Rakefile source (requires the Echoe gem):
30
- #
31
- #
32
- # require 'echoe'
33
- #
34
- # Echoe.new("ultrasphinx") do |p|
35
- # p.project = "fauna"
36
- # p.summary = "Ruby on Rails configurator and client to the Sphinx fulltext search engine."
37
- # p.url = "http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/"
38
- # p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
39
- # p.rdoc_pattern = /is_indexed.rb|search.rb|spell.rb|ultrasphinx.rb|^README|TODO|DEPLOY|RAKE_TASKS|CHANGELOG|^LICENSE/
40
- # p.dependencies = "chronic"
41
- # p.test_pattern = ["test/integration/*.rb", "test/unit/*.rb"]
42
- # p.rcov_options << '--include-file test\/integration\/app\/vendor\/plugins\/ultrasphinx\/lib\/.*\.rb --include-file '
43
- # end
44
- #
45
- # desc "Run all the tests for every database adapter"
46
- # task "test_all" do
47
- # ['mysql', 'postgresql'].each do |adapter|
48
- # ENV['DB'] = adapter
49
- # ENV['PRODUCTION'] = nil
50
- # STDERR.puts "#{'='*80}\nDevelopment mode for #{adapter}\n#{'='*80}"
51
- # system("rake test:multi_rails:all")
52
- #
53
- # ENV['PRODUCTION'] = '1'
54
- # STDERR.puts "#{'='*80}\nProduction mode for #{adapter}\n#{'='*80}"
55
- # system("rake test:multi_rails:all")
56
- # end
57
- # end
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<chronic>, [">= 0"])
30
+ else
31
+ s.add_dependency(%q<chronic>, [">= 0"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<chronic>, [">= 0"])
35
+ end
36
+ end
@@ -5,16 +5,28 @@ client and the original PHP client - credit where credit's due, after all.
5
5
  It does not follow the same syntax as those two, though (not much point writing this otherwise) -
6
6
  opting for a more Ruby-like structure.
7
7
 
8
- While it doesn't (yet) exist as a gem, you can obtain the sourcecode via subversion. If you
8
+ The easiest way to install is to grab the gem (available since 0.9.8r1112 only):
9
+
10
+ sudo gem install riddle
11
+
12
+ However, if you're so inclined, you can grab sourcecode via subversion. If you
9
13
  are after a specific release, use the tag as follows:
10
14
 
11
- svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-r1112 riddle
15
+ svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/tags/0.9.8-rc2 riddle
12
16
 
13
17
  Or for the most current, just use trunk:
14
18
 
15
19
  svn co http://rails-oceania.googlecode.com/svn/patallan/riddle/trunk riddle
16
20
 
17
- Please note that at the time of writing, only 0.9.8r871 through to 0.9.8r1112 are supported.
21
+ Please note that at the time of writing, the following versions are supported (if you get the appropriate tag):
22
+
23
+ * 0.9.8-r871
24
+ * 0.9.8-r909
25
+ * 0.9.8-r985
26
+ * 0.9.8-r1065
27
+ * 0.9.8-r1112
28
+ * 0.9.8-rc1 (gem version: 0.9.8.1198)
29
+ * 0.9.8-rc2 (gem version: 0.9.8.1231)
18
30
 
19
31
  To get started, just instantiate a Client object:
20
32
 
@@ -57,4 +69,6 @@ total number of matches (which may be greater than the maximum available), and t
57
69
  that the query took to run.
58
70
 
59
71
  <tt>:status</tt> is the error code for the query - and if there was a related warning, it will be under
60
- the <tt>:warning</tt> key. Fatal errors will be described under <tt>:error</tt>.
72
+ the <tt>:warning</tt> key. Fatal errors will be described under <tt>:error</tt>.
73
+
74
+ If you've installed the gem and wondering why there's no tests - check out the svn version. I've kept the specs out of the gem as I have a decent amount of test data in there, which really isn't needed unless you want to submit patches.
@@ -1,4 +1,5 @@
1
1
  require 'rake'
2
+ require 'rake/packagetask'
2
3
  require 'rake/rdoctask'
3
4
  require 'spec/rake/spectask'
4
5
  require 'rdoc/rdoc'
@@ -9,11 +9,17 @@ module Riddle #:nodoc:
9
9
  end
10
10
 
11
11
  module Version #:nodoc:
12
- Major = 0
13
- Minor = 9
14
- Tiny = 8
15
- Rev = 1112
12
+ Major = 0
13
+ Minor = 9
14
+ Tiny = 8
15
+ # Revision number for RubyForge's sake, taken from what Sphinx
16
+ # outputs to the command line.
17
+ Rev = 1231
18
+ # Release number to mark my own fixes, beyond feature parity with
19
+ # Sphinx itself.
20
+ Release = 0
16
21
 
17
- String = [Major, Minor, Tiny].join('.') + "r#{Rev}"
22
+ String = [Major, Minor, Tiny].join('.') + "rc2"
23
+ GemVersion = [Major, Minor, Tiny, Rev, Release].join('.')
18
24
  end
19
25
  end
@@ -26,15 +26,17 @@ module Riddle
26
26
  #
27
27
  class Client
28
28
  Commands = {
29
- :search => 0, # SEARCHD_COMMAND_SEARCH
30
- :excerpt => 1, # SEARCHD_COMMAND_EXCERPT
31
- :update => 2 # SEARCHD_COMMAND_UPDATE
29
+ :search => 0, # SEARCHD_COMMAND_SEARCH
30
+ :excerpt => 1, # SEARCHD_COMMAND_EXCERPT
31
+ :update => 2, # SEARCHD_COMMAND_UPDATE
32
+ :keywords => 3 # SEARCHD_COMMAND_KEYWORDS
32
33
  }
33
34
 
34
35
  Versions = {
35
- :search => 0x112, # VER_COMMAND_SEARCH
36
- :excerpt => 0x100, # VER_COMMAND_EXCERPT
37
- :update => 0x101 # VER_COMMAND_UPDATE
36
+ :search => 0x113, # VER_COMMAND_SEARCH
37
+ :excerpt => 0x100, # VER_COMMAND_EXCERPT
38
+ :update => 0x101, # VER_COMMAND_UPDATE
39
+ :keywords => 0x100 # VER_COMMAND_KEYWORDS
38
40
  }
39
41
 
40
42
  Statuses = {
@@ -50,7 +52,7 @@ module Riddle
50
52
  :phrase => 2, # SPH_MATCH_PHRASE
51
53
  :boolean => 3, # SPH_MATCH_BOOLEAN
52
54
  :extended => 4, # SPH_MATCH_EXTENDED
53
- :fullsacn => 5, # SPH_MATCH_FULLSCAN
55
+ :fullscan => 5, # SPH_MATCH_FULLSCAN
54
56
  :extended2 => 6 # SPH_MATCH_EXTENDED2
55
57
  }
56
58
 
@@ -158,8 +160,8 @@ module Riddle
158
160
 
159
161
  # Append a query to the queue. This uses the same parameters as the query
160
162
  # method.
161
- def append_query(search, index = '*')
162
- @queue << query_message(search, index)
163
+ def append_query(search, index = '*', comments = '')
164
+ @queue << query_message(search, index, comments)
163
165
  end
164
166
 
165
167
  # Run all the queries currently in the queue. This will return an array of
@@ -204,14 +206,9 @@ module Riddle
204
206
 
205
207
  result[:matches] << {:doc => doc, :weight => weight, :index => i, :attributes => {}}
206
208
  result[:attribute_names].each do |attr|
207
- case result[:attributes][attr]
208
- when AttributeTypes[:float]
209
- result[:matches].last[:attributes][attr] = response.next_float
210
- when AttributeTypes[:multi]
211
- result[:matches].last[:attributes][attr] = response.next_int_array
212
- else
213
- result[:matches].last[:attributes][attr] = response.next_int
214
- end
209
+ result[:matches].last[:attributes][attr] = attribute_from_type(
210
+ result[:attributes][attr], response
211
+ )
215
212
  end
216
213
  end
217
214
 
@@ -275,8 +272,8 @@ module Riddle
275
272
  # related warning, it will be under the <tt>:warning</tt> key. Fatal errors
276
273
  # will be described under <tt>:error</tt>.
277
274
  #
278
- def query(search, index = '*')
279
- @queue << query_message(search, index)
275
+ def query(search, index = '*', comments = '')
276
+ @queue << query_message(search, index, comments)
280
277
  self.run.first
281
278
  end
282
279
 
@@ -358,6 +355,30 @@ module Riddle
358
355
  response.next_int
359
356
  end
360
357
 
358
+ # Generates a keyword list for a given query. Each keyword is represented
359
+ # by a hash, with keys :tokenised and :normalised. If return_hits is set to
360
+ # true it will also report on the number of hits and documents for each
361
+ # keyword (see :hits and :docs keys respectively).
362
+ def keywords(query, index, return_hits = false)
363
+ response = Response.new request(
364
+ :keywords,
365
+ keywords_message(query, index, return_hits)
366
+ )
367
+
368
+ (0...response.next_int).collect do
369
+ hash = {}
370
+ hash[:tokenised] = response.next
371
+ hash[:normalised] = response.next
372
+
373
+ if return_hits
374
+ hash[:docs] = response.next_int
375
+ hash[:hits] = response.next_int
376
+ end
377
+
378
+ hash
379
+ end
380
+ end
381
+
361
382
  private
362
383
 
363
384
  # Connects to the Sphinx daemon, and yields a socket to use. The socket is
@@ -439,7 +460,7 @@ module Riddle
439
460
  end
440
461
 
441
462
  # Generation of the message to send to Sphinx for a search.
442
- def query_message(search, index)
463
+ def query_message(search, index, comments = '')
443
464
  message = Message.new
444
465
 
445
466
  # Mode, Limits, Sort Mode
@@ -500,6 +521,8 @@ module Riddle
500
521
  message.append_int val
501
522
  end
502
523
 
524
+ message.append_string comments
525
+
503
526
  message.to_s
504
527
  end
505
528
 
@@ -544,5 +567,27 @@ module Riddle
544
567
 
545
568
  message.to_s
546
569
  end
570
+
571
+ # Generates the simple message to send to the daemon for a keywords request.
572
+ def keywords_message(query, index, return_hits)
573
+ message = Message.new
574
+
575
+ message.append_string query
576
+ message.append_string index
577
+ message.append_int return_hits ? 1 : 0
578
+
579
+ message.to_s
580
+ end
581
+
582
+ def attribute_from_type(type, response)
583
+ type -= AttributeTypes[:multi] if is_multi = type > AttributeTypes[:multi]
584
+
585
+ case type
586
+ when AttributeTypes[:float]
587
+ is_multi ? response.next_float_array : response.next_float
588
+ else
589
+ is_multi ? response.next_int_array : response.next_int
590
+ end
591
+ end
547
592
  end
548
593
  end