ultrasphinx 1.6.7 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +2 -0
  3. data/DEPLOYMENT_NOTES +29 -0
  4. data/Manifest +7 -2
  5. data/RAKE_TASKS +15 -0
  6. data/README +14 -17
  7. data/TODO +7 -1
  8. data/examples/default.base +16 -2
  9. data/lib/ultrasphinx.rb +2 -2
  10. data/lib/ultrasphinx/associations.rb +25 -0
  11. data/lib/ultrasphinx/configure.rb +26 -16
  12. data/lib/ultrasphinx/fields.rb +7 -4
  13. data/lib/ultrasphinx/is_indexed.rb +37 -25
  14. data/lib/ultrasphinx/search.rb +1 -0
  15. data/lib/ultrasphinx/search/internals.rb +10 -3
  16. data/lib/ultrasphinx/search/parser.rb +14 -11
  17. data/lib/ultrasphinx/ultrasphinx.rb +6 -4
  18. data/test/integration/app/app/models/geo/address.rb +1 -1
  19. data/test/integration/app/app/models/geo/country.rb +4 -0
  20. data/test/integration/app/config/boot.rb +95 -32
  21. data/test/integration/app/config/environment.rb +4 -1
  22. data/test/integration/app/config/environments/development.rb +4 -4
  23. data/test/integration/app/config/ultrasphinx/development.conf.canonical +45 -13
  24. data/test/integration/app/db/migrate/009_create_countries.rb +11 -0
  25. data/test/integration/app/test/fixtures/countries.yml +1 -0
  26. data/test/integration/configure_test.rb +14 -11
  27. data/test/integration/search_test.rb +1 -0
  28. data/test/integration/server_test.rb +2 -2
  29. data/test/setup.rb +0 -3
  30. data/test/teardown.rb +0 -0
  31. data/test/test_helper.rb +1 -6
  32. data/ultrasphinx.gemspec +21 -7
  33. data/vendor/riddle/README +2 -2
  34. data/vendor/riddle/Rakefile +94 -0
  35. data/vendor/riddle/lib/riddle.rb +1 -1
  36. data/vendor/riddle/lib/riddle/client.rb +18 -6
  37. data/vendor/riddle/lib/riddle/client/filter.rb +3 -1
  38. data/vendor/riddle/lib/riddle/client/message.rb +1 -1
  39. data/vendor/riddle/lib/riddle/client/response.rb +1 -1
  40. data/vendor/riddle/spec/fixtures/data/anchor.bin +0 -0
  41. data/vendor/riddle/spec/fixtures/data/filter_floats.bin +0 -0
  42. data/vendor/riddle/spec/fixtures/data/filter_floats_exclude.bin +0 -0
  43. data/vendor/riddle/spec/sphinx_helper.rb +1 -0
  44. data/vendor/riddle/spec/unit/message_spec.rb +3 -3
  45. data/vendor/riddle/spec/unit/response_spec.rb +2 -2
  46. metadata +10 -5
  47. metadata.gz.sig +0 -0
  48. data/test/integration/app/config/ultrasphinx/development.conf +0 -159
  49. data/test/integration/app/db/schema.rb +0 -52
@@ -120,6 +120,7 @@ Note that your database is never changed by anything Ultrasphinx does.
120
120
  self.client_options ||= HashWithIndifferentAccess.new({
121
121
  :with_subtotals => false,
122
122
  :ignore_missing_records => false,
123
+ :max_missing_records => 5, # Has no effect if :ignore_missing_records => false
123
124
  :max_retries => 4,
124
125
  :retry_sleep_time => 0.5,
125
126
  :max_facets => 100,
@@ -2,6 +2,7 @@
2
2
  module Ultrasphinx
3
3
  class Search
4
4
  module Internals
5
+ include Associations
5
6
 
6
7
  # These methods are kept stateless to ease debugging
7
8
 
@@ -184,9 +185,10 @@ module Ultrasphinx
184
185
  when 'fields'
185
186
  [configuration['field'], ""]
186
187
  when 'include'
188
+ association_model = get_association_model(klass, configuration)
187
189
  # XXX Only handles the basic case. No test coverage.
188
190
  ["included.#{configuration['field']}",
189
- (configuration['association_sql'] or "LEFT OUTER JOIN #{configuration['table']} AS included ON included.#{configuration['class_name'].constantize.primary_key} = #{klass.table_name}.#{configuration['class_name'].underscore}_id")
191
+ (configuration['association_sql'] or "LEFT OUTER JOIN #{configuration['table']} AS included ON included.#{association_model.primary_key} = #{klass.table_name}.#{association_model.class_name.underscore}_id")
190
192
  ]
191
193
  when 'concatenate'
192
194
  # Wait for someone to complain before worrying about this
@@ -203,8 +205,8 @@ module Ultrasphinx
203
205
  raise ConfigurationError, "no classes were correctly configured for text faceting on '#{facet}'" if configured_classes.empty?
204
206
 
205
207
  FACET_CACHE[facet]
206
- end
207
-
208
+ end
209
+
208
210
  # Inverse-modulus map the Sphinx ids to the table-specific ids
209
211
  def convert_sphinx_ids(sphinx_ids)
210
212
  sphinx_ids.sort_by do |item|
@@ -251,6 +253,11 @@ module Ultrasphinx
251
253
  result._metaclass.send('define_method', 'result_index') { i }
252
254
  end
253
255
 
256
+ if ids.size - results.size > Ultrasphinx::Search.client_options['max_missing_records']
257
+ # Never reached if Ultrasphinx::Search.client_options['ignore_missing_records'] is false
258
+ raise ConfigurationError, "Too many results for this query returned ActiveRecord::RecordNotFound. The index is probably out of date"
259
+ end
260
+
254
261
  results
255
262
  end
256
263
 
@@ -1,9 +1,12 @@
1
1
 
2
2
  module Ultrasphinx
3
3
  class Search
4
- module Parser
5
-
6
- class Error < RuntimeError; end
4
+ module Parser
5
+ # We could rewrite this in Treetop, but since it works well, what's the point? It's
6
+ # probably faster this way. Ragel would speed it up, but be too much work.
7
+
8
+ class Error < RuntimeError
9
+ end
7
10
 
8
11
  OPERATORS = {
9
12
  'OR' => '|',
@@ -32,7 +35,7 @@ module Ultrasphinx
32
35
  token_hash.sort_by do |key, value|
33
36
  key or ""
34
37
  end.each do |field, contents|
35
- # first operator always goes outside
38
+ # First operator always goes outside
36
39
  query << contents.first.first
37
40
 
38
41
  query << "@#{field}" if field
@@ -66,24 +69,24 @@ module Ultrasphinx
66
69
 
67
70
  query.each_with_index do |subtoken, index|
68
71
 
69
- # recurse for parens, if necessary
72
+ # Recurse for parens, if necessary
70
73
  if subtoken =~ /^(.*?)\((.*)\)(.*?$)/
71
74
  subtoken = query[index] = "#{$1}(#{parse $2})#{$3}"
72
75
  end
73
76
 
74
- # reappend missing closing quotes
77
+ # Reappend missing closing quotes
75
78
  if subtoken =~ /(^|\:)\"/
76
79
  subtoken = subtoken.chomp('"') + '"'
77
80
  end
78
81
 
79
- # strip parentheses within quoted strings
82
+ # Strip parentheses within quoted strings
80
83
  if subtoken =~ /\"(.*)\"/
81
84
  subtoken.sub!($1, $1.gsub(/[()]/, ''))
82
85
  end
83
86
 
84
87
  # add to the stream, converting the operator
85
88
  if !has_operator
86
- if OPERATORS.to_a.flatten.include? subtoken and index != (query.size - 1) # operators at the end of the string are not parsed
89
+ if OPERATORS.to_a.flatten.include? subtoken and index != (query.size - 1) # Operators at the end of the string are not parsed
87
90
  token_stream << OPERATORS[subtoken] || subtoken
88
91
  has_operator = true # flip
89
92
  else
@@ -92,7 +95,7 @@ module Ultrasphinx
92
95
  end
93
96
  else
94
97
  if OPERATORS.to_a.flatten.include? subtoken
95
- # drop extra operator
98
+ # Drop extra operator
96
99
  else
97
100
  token_stream << subtoken
98
101
  has_operator = false # flop
@@ -108,9 +111,9 @@ module Ultrasphinx
108
111
  def token_stream_to_hash(token_stream)
109
112
  token_hash = Hash.new([])
110
113
  token_stream.map do |operator, content|
111
- # remove some spaces
114
+ # Remove some spaces
112
115
  content.gsub!(/^"\s+|\s+"$/, '"')
113
- # convert fields into sphinx style, reformat the stream object
116
+ # Convert fields into sphinx style, reformat the stream object
114
117
  if content =~ /(.*?):(.*)/
115
118
  token_hash[$1] += [[operator, $2]]
116
119
  else
@@ -56,13 +56,15 @@ module Ultrasphinx
56
56
  open("#{THIS_DIR}/postgresql/#{name}.sql").read.gsub(/\s+/, ' ')
57
57
  end
58
58
 
59
- ADAPTER_SQL_FUNCTIONS = {
59
+ SQL_FUNCTIONS = {
60
60
  'mysql' => {
61
61
  'group_concat' => "CAST(GROUP_CONCAT(DISTINCT ? SEPARATOR ' ') AS CHAR)",
62
+ 'range_cast' => "?",
62
63
  'stored_procedures' => {}
63
64
  },
64
65
  'postgresql' => {
65
66
  'group_concat' => "GROUP_CONCAT(?)",
67
+ 'range_cast' => "cast(coalesce(?,1) AS integer)",
66
68
  'stored_procedures' => Hash[*(
67
69
  ['hex_to_int', 'group_concat', 'concat_ws', 'unix_timestamp', 'crc32'].map do |name|
68
70
  [name, load_stored_procedure(name)]
@@ -72,7 +74,7 @@ module Ultrasphinx
72
74
  }
73
75
  }
74
76
 
75
- ADAPTER_DEFAULTS = {
77
+ DEFAULTS = {
76
78
  'mysql' => %(
77
79
  type = mysql
78
80
  sql_query_pre = SET SESSION group_concat_max_len = 65535
@@ -80,14 +82,14 @@ sql_query_pre = SET NAMES utf8
80
82
  ),
81
83
  'postgresql' => %(
82
84
  type = pgsql
83
- sql_query_pre = ) + ADAPTER_SQL_FUNCTIONS['postgresql']['stored_procedures'].values.join(' ') + %(
85
+ sql_query_pre = ) + SQL_FUNCTIONS['postgresql']['stored_procedures'].values.join(' ') + %(
84
86
  )
85
87
  }
86
88
 
87
89
  ADAPTER = ActiveRecord::Base.connection.instance_variable_get("@config")[:adapter] rescue 'mysql'
88
90
 
89
91
  # Install the stored procedures
90
- ADAPTER_SQL_FUNCTIONS[ADAPTER]['stored_procedures'].each do |key, value|
92
+ SQL_FUNCTIONS[ADAPTER]['stored_procedures'].each do |key, value|
91
93
  ActiveRecord::Base.connection.execute(value)
92
94
  end
93
95
 
@@ -4,5 +4,5 @@ class Geo::Address < ActiveRecord::Base
4
4
 
5
5
  is_indexed 'fields' => ['name'],
6
6
  'concatenate' => [{'fields' => ['line_1', 'line_2', 'city', 'province_region', 'zip_postal_code'], 'as' => 'content'}],
7
- 'include' => [{'class_name' => 'Geo::State', 'field' => 'name', 'as' => 'state'}]
7
+ 'include' => [{'association_name' => 'state', 'field' => 'name', 'as' => 'state'}]
8
8
  end
@@ -0,0 +1,4 @@
1
+
2
+ class Geo::Country < ActiveRecord::Base
3
+ is_indexed :fields => ['name']
4
+ end
@@ -1,45 +1,108 @@
1
- # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
2
3
 
3
- unless defined?(RAILS_ROOT)
4
- root_path = File.join(File.dirname(__FILE__), '..')
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
5
 
6
- unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
7
- require 'pathname'
8
- root_path = Pathname.new(root_path).cleanpath(true).to_s
9
- end
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
10
14
 
11
- RAILS_ROOT = root_path
12
- end
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
13
26
 
14
- unless defined?(Rails::Initializer)
15
- if File.directory?("#{RAILS_ROOT}/vendor/rails")
16
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17
- else
18
- require 'rubygems'
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exists?(preinitializer_path)
29
+ end
19
30
 
20
- environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
21
- environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
22
- rails_gem_version = $1
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
23
35
 
24
- if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
25
- # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
26
- rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
27
42
 
28
- if rails_gem
29
- gem "rails", "=#{rails_gem.version.version}"
30
- require rails_gem.full_gem_path + '/lib/initializer'
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ end
47
+ end
48
+
49
+ class GemBoot < Boot
50
+ def load_initializer
51
+ self.class.load_rubygems
52
+ load_rails_gem
53
+ require 'initializer'
54
+ end
55
+
56
+ def load_rails_gem
57
+ if version = self.class.gem_version
58
+ gem 'rails', version
31
59
  else
32
- STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
33
- Install the missing gem with 'gem install -v=#{version} rails', or
34
- change environment.rb to define RAILS_GEM_VERSION with your desired version.
35
- )
60
+ gem 'rails'
61
+ end
62
+ rescue Gem::LoadError => load_error
63
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
64
+ exit 1
65
+ end
66
+
67
+ class << self
68
+ def rubygems_version
69
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
70
+ end
71
+
72
+ def gem_version
73
+ if defined? RAILS_GEM_VERSION
74
+ RAILS_GEM_VERSION
75
+ elsif ENV.include?('RAILS_GEM_VERSION')
76
+ ENV['RAILS_GEM_VERSION']
77
+ else
78
+ parse_gem_version(read_environment_rb)
79
+ end
80
+ end
81
+
82
+ def load_rubygems
83
+ require 'rubygems'
84
+
85
+ unless rubygems_version >= '0.9.4'
86
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
87
+ exit 1
88
+ end
89
+
90
+ rescue LoadError
91
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
36
92
  exit 1
37
93
  end
38
- else
39
- gem "rails"
40
- require 'initializer'
94
+
95
+ def parse_gem_version(text)
96
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/
97
+ end
98
+
99
+ private
100
+ def read_environment_rb
101
+ File.read("#{RAILS_ROOT}/config/environment.rb")
102
+ end
41
103
  end
42
104
  end
43
-
44
- Rails::Initializer.run(:set_load_path)
45
105
  end
106
+
107
+ # All that for this:
108
+ Rails.boot!
@@ -1,8 +1,11 @@
1
1
 
2
+ RAILS_GEM_VERSION = ENV['MULTIRAILS_RAILS_VERSION'] if ENV['MULTIRAILS_RAILS_VERSION']
3
+
2
4
  require File.join(File.dirname(__FILE__), 'boot')
5
+ require 'action_controller'
3
6
 
4
7
  Rails::Initializer.run do |config|
5
- config.action_controller.session = { :session_key => "_myapp_session", :secret => "this is a super secret phrase" }
8
+ config.action_controller.session = { :session_key => "_myapp_session", :secret => "7c74979e7db2230f84adbb4b3eb77d05" }
6
9
  config.load_paths << "#{RAILS_ROOT}/app/models/person" # moduleless model path
7
10
  end
8
11
 
@@ -1,7 +1,7 @@
1
- config.cache_classes = false
1
+ config.cache_classes = ENV['PRODUCTION']
2
2
  config.whiny_nils = true
3
3
  config.action_controller.consider_all_requests_local = true
4
- config.action_controller.perform_caching = false
5
- config.action_view.cache_template_extensions = false
6
- config.action_view.debug_rjs = true
4
+ config.action_controller.perform_caching = ENV['PRODUCTION']
5
+ config.action_view.cache_template_extensions = false
6
+ config.action_view.debug_rjs = true
7
7
  config.action_mailer.raise_delivery_errors = false
@@ -1,5 +1,5 @@
1
1
 
2
- # Auto-generated at Wed Dec 12 02:47:44 -0500 2007.
2
+ # Auto-generated at Sat Jan 12 08:05:26 -0500 2008.
3
3
  # Hand modifications will be overwritten.
4
4
  # /Users/eweaver/Desktop/projects/chow/vendor/plugins/ultrasphinx/test/integration/app/config/ultrasphinx/default.base
5
5
  indexer {
@@ -33,8 +33,8 @@ sql_db = ultrasphinx_development
33
33
  sql_host = localhost
34
34
  sql_pass =
35
35
  sql_user = root
36
- sql_query_range = SELECT MIN(id), MAX(id) FROM states
37
- sql_query = SELECT (states.id * 4 + 0) AS id, CAST(GROUP_CONCAT(DISTINCT addresses.name SEPARATOR ' ') AS CHAR) AS address_name, 0 AS capitalization, 'Geo::State' AS class, 0 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS company_two, '' AS content, 18000 AS created_at, 0 AS deleted, '' AS email, '' AS login, '' AS mission_statement, '' AS name, '' AS state, 0 AS user_id FROM states LEFT OUTER JOIN addresses AS addresses ON states.id = addresses.state_id WHERE states.id >= $start AND states.id <= $end GROUP BY states.id
36
+ sql_query_range = SELECT MIN(id) , MAX(id) FROM states
37
+ sql_query = SELECT (states.id * 5 + 0) AS id, CAST(GROUP_CONCAT(DISTINCT addresses.name SEPARATOR ' ') AS CHAR) AS address_name, 0 AS capitalization, 'Geo::State' AS class, 0 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS company_two, '' AS content, 18000 AS created_at, 0 AS deleted, '' AS email, '' AS login, '' AS mission_statement, '' AS name, '' AS state, 0 AS user_id FROM states LEFT OUTER JOIN addresses AS addresses ON states.id = addresses.state_id WHERE states.id >= $start AND states.id <= $end GROUP BY states.id
38
38
 
39
39
  sql_group_column = capitalization
40
40
  sql_group_column = class_id
@@ -43,7 +43,7 @@ sql_date_column = created_at
43
43
  sql_group_column = deleted
44
44
  sql_str2ordinal_column = mission_statement
45
45
  sql_group_column = user_id
46
- sql_query_info = SELECT * FROM states WHERE states.id = (($id - 0) / 4)
46
+ sql_query_info = SELECT * FROM states WHERE states.id = (($id - 0) / 5)
47
47
  }
48
48
 
49
49
 
@@ -64,8 +64,8 @@ sql_db = ultrasphinx_development
64
64
  sql_host = localhost
65
65
  sql_pass =
66
66
  sql_user = root
67
- sql_query_range = SELECT MIN(id), MAX(id) FROM sellers
68
- sql_query = SELECT (sellers.id * 4 + 1) AS id, '' AS address_name, sellers.capitalization AS capitalization, 'Seller' AS class, 1 AS class_id, '' AS company, sellers.company_name AS company_name, CRC32(sellers.company_name) AS company_name_facet, '' AS company_two, '' AS content, UNIX_TIMESTAMP(sellers.created_at) AS created_at, 0 AS deleted, '' AS email, '' AS login, sellers.mission_statement AS mission_statement, '' AS name, '' AS state, sellers.user_id AS user_id FROM sellers WHERE sellers.id >= $start AND sellers.id <= $end GROUP BY sellers.id
67
+ sql_query_range = SELECT MIN(id) , MAX(id) FROM sellers
68
+ sql_query = SELECT (sellers.id * 5 + 1) AS id, '' AS address_name, sellers.capitalization AS capitalization, 'Seller' AS class, 1 AS class_id, '' AS company, sellers.company_name AS company_name, CRC32(sellers.company_name) AS company_name_facet, '' AS company_two, '' AS content, UNIX_TIMESTAMP(sellers.created_at) AS created_at, 0 AS deleted, '' AS email, '' AS login, sellers.mission_statement AS mission_statement, '' AS name, '' AS state, sellers.user_id AS user_id FROM sellers WHERE sellers.id >= $start AND sellers.id <= $end GROUP BY sellers.id
69
69
 
70
70
  sql_group_column = capitalization
71
71
  sql_group_column = class_id
@@ -74,7 +74,7 @@ sql_date_column = created_at
74
74
  sql_group_column = deleted
75
75
  sql_str2ordinal_column = mission_statement
76
76
  sql_group_column = user_id
77
- sql_query_info = SELECT * FROM sellers WHERE sellers.id = (($id - 1) / 4)
77
+ sql_query_info = SELECT * FROM sellers WHERE sellers.id = (($id - 1) / 5)
78
78
  }
79
79
 
80
80
 
@@ -95,8 +95,8 @@ sql_db = ultrasphinx_development
95
95
  sql_host = localhost
96
96
  sql_pass =
97
97
  sql_user = root
98
- sql_query_range = SELECT MIN(id), MAX(id) FROM addresses
99
- sql_query = SELECT (addresses.id * 4 + 2) AS id, '' AS address_name, 0 AS capitalization, 'Geo::Address' AS class, 2 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS company_two, CONCAT_WS(' ', addresses.line_1, addresses.line_2, addresses.city, addresses.province_region, addresses.zip_postal_code) AS content, 18000 AS created_at, 0 AS deleted, '' AS email, '' AS login, '' AS mission_statement, addresses.name AS name, states.name AS state, 0 AS user_id FROM addresses LEFT OUTER JOIN states AS states ON states.id = addresses.state_id WHERE addresses.id >= $start AND addresses.id <= $end GROUP BY addresses.id
98
+ sql_query_range = SELECT MIN(id) , MAX(id) FROM addresses
99
+ sql_query = SELECT (addresses.id * 5 + 2) AS id, '' AS address_name, 0 AS capitalization, 'Geo::Address' AS class, 2 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS company_two, CONCAT_WS(' ', addresses.line_1, addresses.line_2, addresses.city, addresses.province_region, addresses.zip_postal_code) AS content, 18000 AS created_at, 0 AS deleted, '' AS email, '' AS login, '' AS mission_statement, addresses.name AS name, states.name AS state, 0 AS user_id FROM addresses LEFT OUTER JOIN states AS states ON states.id = addresses.state_id WHERE addresses.id >= $start AND addresses.id <= $end GROUP BY addresses.id
100
100
 
101
101
  sql_group_column = capitalization
102
102
  sql_group_column = class_id
@@ -105,7 +105,7 @@ sql_date_column = created_at
105
105
  sql_group_column = deleted
106
106
  sql_str2ordinal_column = mission_statement
107
107
  sql_group_column = user_id
108
- sql_query_info = SELECT * FROM addresses WHERE addresses.id = (($id - 2) / 4)
108
+ sql_query_info = SELECT * FROM addresses WHERE addresses.id = (($id - 2) / 5)
109
109
  }
110
110
 
111
111
 
@@ -126,8 +126,8 @@ sql_db = ultrasphinx_development
126
126
  sql_host = localhost
127
127
  sql_pass =
128
128
  sql_user = root
129
- sql_query_range = SELECT MIN(id), MAX(id) FROM users
130
- sql_query = SELECT (users.id * 4 + 3) AS id, '' AS address_name, 0 AS capitalization, 'User' AS class, 3 AS class_id, sellers.company_name AS company, '' AS company_name, 0 AS company_name_facet, REPLACE(sellers_two.company_name, '6', ' replacement ') AS company_two, '' AS content, 18000 AS created_at, users.deleted AS deleted, users.email AS email, users.login AS login, '' AS mission_statement, '' AS name, '' AS state, 0 AS user_id FROM users LEFT OUTER JOIN sellers AS sellers ON users.id = sellers.user_id LEFT OUTER JOIN sellers AS sellers_two ON users.id = sellers_two.user_id WHERE users.id >= $start AND users.id <= $end AND (deleted = '0') GROUP BY users.id
129
+ sql_query_range = SELECT MIN(id) , MAX(id) FROM users
130
+ sql_query = SELECT (users.id * 5 + 3) AS id, '' AS address_name, 0 AS capitalization, 'User' AS class, 3 AS class_id, sellers.company_name AS company, '' AS company_name, 0 AS company_name_facet, REPLACE(sellers_two.company_name, '6', ' replacement ') AS company_two, '' AS content, 18000 AS created_at, users.deleted AS deleted, users.email AS email, users.login AS login, '' AS mission_statement, '' AS name, '' AS state, 0 AS user_id FROM users LEFT OUTER JOIN sellers AS sellers ON users.id = sellers.user_id LEFT OUTER JOIN sellers AS sellers_two ON users.id = sellers_two.user_id WHERE users.id >= $start AND users.id <= $end AND (deleted = '0') GROUP BY users.id
131
131
 
132
132
  sql_group_column = capitalization
133
133
  sql_group_column = class_id
@@ -136,7 +136,38 @@ sql_date_column = created_at
136
136
  sql_group_column = deleted
137
137
  sql_str2ordinal_column = mission_statement
138
138
  sql_group_column = user_id
139
- sql_query_info = SELECT * FROM users WHERE users.id = (($id - 3) / 4)
139
+ sql_query_info = SELECT * FROM users WHERE users.id = (($id - 3) / 5)
140
+ }
141
+
142
+
143
+ # Source configuration
144
+
145
+ source geo__countries
146
+ {
147
+ strip_html = 0
148
+ sql_range_step = 20000
149
+ index_html_attrs =
150
+ sql_query_post =
151
+
152
+ type = mysql
153
+ sql_query_pre = SET SESSION group_concat_max_len = 65535
154
+ sql_query_pre = SET NAMES utf8
155
+
156
+ sql_db = ultrasphinx_development
157
+ sql_host = localhost
158
+ sql_pass =
159
+ sql_user = root
160
+ sql_query_range = SELECT MIN(id) , MAX(id) FROM countries
161
+ sql_query = SELECT (countries.id * 5 + 4) AS id, '' AS address_name, 0 AS capitalization, 'Geo::Country' AS class, 4 AS class_id, '' AS company, '' AS company_name, 0 AS company_name_facet, '' AS company_two, '' AS content, 18000 AS created_at, 0 AS deleted, '' AS email, '' AS login, '' AS mission_statement, countries.name AS name, '' AS state, 0 AS user_id FROM countries WHERE countries.id >= $start AND countries.id <= $end GROUP BY countries.id
162
+
163
+ sql_group_column = capitalization
164
+ sql_group_column = class_id
165
+ sql_group_column = company_name_facet
166
+ sql_date_column = created_at
167
+ sql_group_column = deleted
168
+ sql_str2ordinal_column = mission_statement
169
+ sql_group_column = user_id
170
+ sql_query_info = SELECT * FROM countries WHERE countries.id = (($id - 4) / 5)
140
171
  }
141
172
 
142
173
 
@@ -145,6 +176,7 @@ sql_query_info = SELECT * FROM users WHERE users.id = (($id - 3) / 4)
145
176
  index complete
146
177
  {
147
178
  source = geo__addresses
179
+ source = geo__countries
148
180
  source = geo__states
149
181
  source = sellers
150
182
  source = users