thinking-sphinx 3.1.4 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +99 -0
- data/.github/actions/test/action.yml +46 -0
- data/.github/workflows/ci.yml +75 -0
- data/.gitignore +7 -2
- data/.travis.yml +31 -16
- data/Appraisals +68 -12
- data/CHANGELOG.markdown +782 -0
- data/Gemfile +13 -4
- data/Procfile.support +2 -0
- data/README.textile +41 -27
- data/Rakefile +2 -0
- data/bin/console +15 -0
- data/bin/loadsphinx +99 -0
- data/bin/testmatrix +48 -0
- data/lib/thinking/sphinx.rb +2 -0
- data/lib/thinking-sphinx.rb +2 -0
- data/lib/thinking_sphinx/active_record/association.rb +2 -0
- data/lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb +3 -1
- data/lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb +2 -0
- data/lib/thinking_sphinx/active_record/association_proxy.rb +3 -2
- data/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb +3 -1
- data/lib/thinking_sphinx/active_record/attribute/type.rb +20 -4
- data/lib/thinking_sphinx/active_record/attribute/values.rb +2 -0
- data/lib/thinking_sphinx/active_record/attribute.rb +2 -0
- data/lib/thinking_sphinx/active_record/base.rb +43 -11
- data/lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb +21 -0
- data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +15 -9
- data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +20 -5
- data/lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb +18 -4
- data/lib/thinking_sphinx/active_record/column.rb +2 -0
- data/lib/thinking_sphinx/active_record/column_sql_presenter.rb +7 -1
- data/lib/thinking_sphinx/active_record/database_adapters/abstract_adapter.rb +2 -0
- data/lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb +9 -1
- data/lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb +2 -0
- data/lib/thinking_sphinx/active_record/database_adapters.rb +3 -1
- data/lib/thinking_sphinx/active_record/depolymorph/association_reflection.rb +32 -0
- data/lib/thinking_sphinx/active_record/depolymorph/base_reflection.rb +32 -0
- data/lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb +40 -0
- data/lib/thinking_sphinx/active_record/depolymorph/overridden_reflection.rb +50 -0
- data/lib/thinking_sphinx/active_record/depolymorph/scoped_reflection.rb +26 -0
- data/lib/thinking_sphinx/active_record/field.rb +2 -0
- data/lib/thinking_sphinx/active_record/filter_reflection.rb +13 -71
- data/lib/thinking_sphinx/active_record/index.rb +7 -5
- data/lib/thinking_sphinx/active_record/interpreter.rb +6 -4
- data/lib/thinking_sphinx/active_record/join_association.rb +5 -1
- data/lib/thinking_sphinx/active_record/log_subscriber.rb +22 -3
- data/lib/thinking_sphinx/active_record/polymorpher.rb +2 -0
- data/lib/thinking_sphinx/active_record/property.rb +2 -0
- data/lib/thinking_sphinx/active_record/property_query.rb +4 -1
- data/lib/thinking_sphinx/active_record/property_sql_presenter.rb +2 -0
- data/lib/thinking_sphinx/active_record/simple_many_query.rb +2 -0
- data/lib/thinking_sphinx/active_record/source_joins.rb +68 -0
- data/lib/thinking_sphinx/active_record/sql_builder/clause_builder.rb +2 -0
- data/lib/thinking_sphinx/active_record/sql_builder/query.rb +13 -0
- data/lib/thinking_sphinx/active_record/sql_builder/statement.rb +2 -0
- data/lib/thinking_sphinx/active_record/sql_builder.rb +5 -18
- data/lib/thinking_sphinx/active_record/sql_source/template.rb +5 -3
- data/lib/thinking_sphinx/active_record/sql_source.rb +35 -9
- data/lib/thinking_sphinx/active_record.rb +14 -1
- data/lib/thinking_sphinx/attribute_types.rb +72 -0
- data/lib/thinking_sphinx/batched_search.rb +2 -0
- data/lib/thinking_sphinx/callbacks/appender.rb +63 -0
- data/lib/thinking_sphinx/callbacks.rb +29 -0
- data/lib/thinking_sphinx/capistrano/v2.rb +2 -0
- data/lib/thinking_sphinx/capistrano/v3.rb +2 -0
- data/lib/thinking_sphinx/capistrano.rb +2 -0
- data/lib/thinking_sphinx/commander.rb +27 -0
- data/lib/thinking_sphinx/commands/base.rb +53 -0
- data/lib/thinking_sphinx/commands/clear_real_time.rb +22 -0
- data/lib/thinking_sphinx/commands/clear_sql.rb +18 -0
- data/lib/thinking_sphinx/commands/configure.rb +15 -0
- data/lib/thinking_sphinx/commands/index_real_time.rb +15 -0
- data/lib/thinking_sphinx/commands/index_sql.rb +25 -0
- data/lib/thinking_sphinx/commands/merge.rb +27 -0
- data/lib/thinking_sphinx/commands/merge_and_update.rb +57 -0
- data/lib/thinking_sphinx/commands/prepare.rb +15 -0
- data/lib/thinking_sphinx/commands/rotate.rb +13 -0
- data/lib/thinking_sphinx/commands/running.rb +15 -0
- data/lib/thinking_sphinx/commands/start_attached.rb +22 -0
- data/lib/thinking_sphinx/commands/start_detached.rb +21 -0
- data/lib/thinking_sphinx/commands/stop.rb +24 -0
- data/lib/thinking_sphinx/commands.rb +20 -0
- data/lib/thinking_sphinx/configuration/consistent_ids.rb +2 -0
- data/lib/thinking_sphinx/configuration/defaults.rb +2 -0
- data/lib/thinking_sphinx/configuration/distributed_indices.rb +3 -1
- data/lib/thinking_sphinx/configuration/duplicate_names.rb +36 -0
- data/lib/thinking_sphinx/configuration/minimum_fields.rb +17 -12
- data/lib/thinking_sphinx/configuration.rb +90 -74
- data/lib/thinking_sphinx/connection/client.rb +74 -0
- data/lib/thinking_sphinx/connection/jruby.rb +58 -0
- data/lib/thinking_sphinx/connection/mri.rb +26 -0
- data/lib/thinking_sphinx/connection.rb +13 -114
- data/lib/thinking_sphinx/core/field.rb +2 -0
- data/lib/thinking_sphinx/core/index.rb +22 -2
- data/lib/thinking_sphinx/core/interpreter.rb +2 -0
- data/lib/thinking_sphinx/core/property.rb +2 -0
- data/lib/thinking_sphinx/core/settings.rb +2 -0
- data/lib/thinking_sphinx/core.rb +2 -0
- data/lib/thinking_sphinx/deletion.rb +33 -13
- data/lib/thinking_sphinx/deltas/default_delta.rb +3 -1
- data/lib/thinking_sphinx/deltas/delete_job.rb +16 -4
- data/lib/thinking_sphinx/deltas/index_job.rb +14 -2
- data/lib/thinking_sphinx/deltas.rb +2 -0
- data/lib/thinking_sphinx/distributed/index.rb +25 -3
- data/lib/thinking_sphinx/distributed.rb +2 -0
- data/lib/thinking_sphinx/errors.rb +47 -3
- data/lib/thinking_sphinx/excerpter.rb +2 -0
- data/lib/thinking_sphinx/facet.rb +4 -3
- data/lib/thinking_sphinx/facet_search.rb +4 -2
- data/lib/thinking_sphinx/float_formatter.rb +2 -0
- data/lib/thinking_sphinx/frameworks/plain.rb +2 -0
- data/lib/thinking_sphinx/frameworks/rails.rb +2 -0
- data/lib/thinking_sphinx/frameworks.rb +2 -0
- data/lib/thinking_sphinx/guard/file.rb +3 -1
- data/lib/thinking_sphinx/guard/files.rb +2 -0
- data/lib/thinking_sphinx/guard/none.rb +7 -0
- data/lib/thinking_sphinx/guard.rb +3 -0
- data/lib/thinking_sphinx/hooks/guard_presence.rb +34 -0
- data/lib/thinking_sphinx/index.rb +2 -0
- data/lib/thinking_sphinx/index_set.rb +27 -4
- data/lib/thinking_sphinx/indexing_strategies/all_at_once.rb +9 -0
- data/lib/thinking_sphinx/indexing_strategies/one_at_a_time.rb +16 -0
- data/lib/thinking_sphinx/interfaces/base.rb +13 -0
- data/lib/thinking_sphinx/interfaces/daemon.rb +27 -0
- data/lib/thinking_sphinx/interfaces/real_time.rb +46 -0
- data/lib/thinking_sphinx/interfaces/sql.rb +53 -0
- data/lib/thinking_sphinx/interfaces.rb +10 -0
- data/lib/thinking_sphinx/logger.rb +2 -0
- data/lib/thinking_sphinx/masks/group_enumerators_mask.rb +6 -4
- data/lib/thinking_sphinx/masks/pagination_mask.rb +2 -0
- data/lib/thinking_sphinx/masks/scopes_mask.rb +8 -0
- data/lib/thinking_sphinx/masks/weight_enumerator_mask.rb +3 -1
- data/lib/thinking_sphinx/masks.rb +2 -0
- data/lib/thinking_sphinx/middlewares/active_record_translator.rb +32 -9
- data/lib/thinking_sphinx/middlewares/geographer.rb +2 -0
- data/lib/thinking_sphinx/middlewares/glazier.rb +14 -1
- data/lib/thinking_sphinx/middlewares/ids_only.rb +2 -0
- data/lib/thinking_sphinx/middlewares/inquirer.rb +3 -1
- data/lib/thinking_sphinx/middlewares/middleware.rb +2 -0
- data/lib/thinking_sphinx/middlewares/sphinxql.rb +18 -16
- data/lib/thinking_sphinx/middlewares/stale_id_checker.rb +3 -1
- data/lib/thinking_sphinx/middlewares/stale_id_filter.rb +4 -2
- data/lib/thinking_sphinx/middlewares/valid_options.rb +25 -0
- data/lib/thinking_sphinx/middlewares.rb +7 -3
- data/lib/thinking_sphinx/panes/attributes_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/distance_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/excerpts_pane.rb +2 -0
- data/lib/thinking_sphinx/panes/weight_pane.rb +3 -1
- data/lib/thinking_sphinx/panes.rb +2 -0
- data/lib/thinking_sphinx/processor.rb +71 -0
- data/lib/thinking_sphinx/query.rb +2 -0
- data/lib/thinking_sphinx/railtie.rb +29 -2
- data/lib/thinking_sphinx/rake_interface.rb +14 -69
- data/lib/thinking_sphinx/real_time/attribute.rb +9 -1
- data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +17 -7
- data/lib/thinking_sphinx/real_time/field.rb +2 -0
- data/lib/thinking_sphinx/real_time/index/template.rb +19 -1
- data/lib/thinking_sphinx/real_time/index.rb +11 -5
- data/lib/thinking_sphinx/real_time/interpreter.rb +10 -6
- data/lib/thinking_sphinx/real_time/populator.rb +12 -14
- data/lib/thinking_sphinx/real_time/processor.rb +36 -0
- data/lib/thinking_sphinx/real_time/property.rb +3 -5
- data/lib/thinking_sphinx/real_time/transcribe_instance.rb +38 -0
- data/lib/thinking_sphinx/real_time/transcriber.rb +63 -15
- data/lib/thinking_sphinx/real_time/translator.rb +39 -0
- data/lib/thinking_sphinx/real_time.rb +22 -1
- data/lib/thinking_sphinx/scopes.rb +6 -0
- data/lib/thinking_sphinx/search/batch_inquirer.rb +2 -0
- data/lib/thinking_sphinx/search/context.rb +11 -0
- data/lib/thinking_sphinx/search/glaze.rb +2 -0
- data/lib/thinking_sphinx/search/merger.rb +2 -0
- data/lib/thinking_sphinx/search/query.rb +9 -1
- data/lib/thinking_sphinx/search/stale_ids_exception.rb +7 -3
- data/lib/thinking_sphinx/search.rb +30 -2
- data/lib/thinking_sphinx/settings.rb +128 -0
- data/lib/thinking_sphinx/sinatra.rb +3 -1
- data/lib/thinking_sphinx/subscribers/populator_subscriber.rb +19 -5
- data/lib/thinking_sphinx/tasks.rb +55 -28
- data/lib/thinking_sphinx/test.rb +3 -1
- data/lib/thinking_sphinx/utf8.rb +2 -0
- data/lib/thinking_sphinx/wildcard.rb +3 -1
- data/lib/thinking_sphinx/with_output.rb +13 -0
- data/lib/thinking_sphinx.rb +35 -4
- data/spec/acceptance/association_scoping_spec.rb +7 -5
- data/spec/acceptance/attribute_access_spec.rb +29 -12
- data/spec/acceptance/attribute_updates_spec.rb +5 -3
- data/spec/acceptance/batch_searching_spec.rb +6 -4
- data/spec/acceptance/big_integers_spec.rb +9 -7
- data/spec/acceptance/excerpts_spec.rb +11 -10
- data/spec/acceptance/facets_spec.rb +29 -16
- data/spec/acceptance/geosearching_spec.rb +22 -10
- data/spec/acceptance/grouping_by_attributes_spec.rb +30 -28
- data/spec/acceptance/index_options_spec.rb +18 -16
- data/spec/acceptance/indexing_spec.rb +5 -3
- data/spec/acceptance/merging_spec.rb +90 -0
- data/spec/acceptance/paginating_search_results_spec.rb +21 -3
- data/spec/acceptance/real_time_updates_spec.rb +103 -5
- data/spec/acceptance/remove_deleted_records_spec.rb +64 -8
- data/spec/acceptance/search_counts_spec.rb +4 -2
- data/spec/acceptance/search_for_just_ids_spec.rb +4 -2
- data/spec/acceptance/searching_across_models_spec.rb +15 -6
- data/spec/acceptance/searching_across_schemas_spec.rb +12 -10
- data/spec/acceptance/searching_on_fields_spec.rb +11 -9
- data/spec/acceptance/searching_with_filters_spec.rb +35 -20
- data/spec/acceptance/searching_with_sti_spec.rb +11 -9
- data/spec/acceptance/searching_within_a_model_spec.rb +44 -17
- data/spec/acceptance/sorting_search_results_spec.rb +21 -19
- data/spec/acceptance/spec_helper.rb +2 -13
- data/spec/acceptance/specifying_sql_spec.rb +118 -62
- data/spec/acceptance/sphinx_scopes_spec.rb +30 -21
- data/spec/acceptance/sql_deltas_spec.rb +35 -9
- data/spec/acceptance/support/database_cleaner.rb +3 -1
- data/spec/acceptance/support/sphinx_controller.rb +25 -9
- data/spec/acceptance/support/sphinx_helpers.rb +17 -2
- data/spec/acceptance/suspended_deltas_spec.rb +14 -12
- data/spec/fixtures/database.yml +1 -1
- data/spec/internal/app/indices/admin_person_index.rb +6 -0
- data/spec/internal/app/indices/album_index.rb +9 -0
- data/spec/internal/app/indices/animal_index.rb +2 -0
- data/spec/internal/app/indices/article_index.rb +10 -3
- data/spec/internal/app/indices/bird_index.rb +2 -0
- data/spec/internal/app/indices/book_index.rb +4 -1
- data/spec/internal/app/indices/car_index.rb +2 -0
- data/spec/internal/app/indices/city_index.rb +2 -0
- data/spec/internal/app/indices/colour_index.rb +7 -0
- data/spec/internal/app/indices/product_index.rb +3 -2
- data/spec/internal/app/indices/tee_index.rb +3 -1
- data/spec/internal/app/indices/user_index.rb +2 -0
- data/spec/internal/app/models/admin/person.rb +6 -0
- data/spec/internal/app/models/album.rb +25 -0
- data/spec/internal/app/models/animal.rb +3 -0
- data/spec/internal/app/models/article.rb +4 -0
- data/spec/internal/app/models/bird.rb +3 -0
- data/spec/internal/app/models/book.rb +9 -5
- data/spec/internal/app/models/car.rb +3 -1
- data/spec/internal/app/models/categorisation.rb +10 -1
- data/spec/internal/app/models/category.rb +2 -0
- data/spec/internal/app/models/city.rb +4 -0
- data/spec/internal/app/models/colour.rb +4 -0
- data/spec/internal/app/models/event.rb +2 -0
- data/spec/internal/app/models/flightless_bird.rb +2 -0
- data/spec/internal/app/models/genre.rb +2 -0
- data/spec/internal/app/models/hardcover.rb +2 -0
- data/spec/internal/app/models/mammal.rb +2 -0
- data/spec/internal/app/models/manufacturer.rb +2 -0
- data/spec/internal/app/models/product.rb +3 -1
- data/spec/internal/app/models/tag.rb +2 -0
- data/spec/internal/app/models/tagging.rb +2 -0
- data/spec/internal/app/models/tee.rb +7 -0
- data/spec/internal/app/models/tweet.rb +2 -0
- data/spec/internal/app/models/user.rb +4 -0
- data/spec/internal/config/database.yml +12 -1
- data/spec/internal/db/schema.rb +13 -1
- data/spec/spec_helper.rb +12 -1
- data/spec/support/json_column.rb +35 -0
- data/spec/support/multi_schema.rb +5 -1
- data/spec/support/mysql.rb +25 -0
- data/spec/support/sphinx_yaml_helpers.rb +8 -1
- data/spec/thinking_sphinx/active_record/association_spec.rb +3 -1
- data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +43 -38
- data/spec/thinking_sphinx/active_record/base_spec.rb +31 -29
- data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +81 -10
- data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +56 -29
- data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +27 -10
- data/spec/thinking_sphinx/active_record/column_spec.rb +15 -13
- data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +39 -0
- data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +7 -5
- data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +26 -12
- data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +15 -13
- data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +50 -48
- data/spec/thinking_sphinx/active_record/field_spec.rb +9 -7
- data/spec/thinking_sphinx/active_record/filter_reflection_spec.rb +113 -80
- data/spec/thinking_sphinx/active_record/index_spec.rb +41 -37
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +62 -59
- data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +16 -14
- data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +69 -67
- data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +146 -154
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +185 -109
- data/spec/thinking_sphinx/attribute_types_spec.rb +52 -0
- data/spec/thinking_sphinx/commands/clear_real_time_spec.rb +46 -0
- data/spec/thinking_sphinx/commands/clear_sql_spec.rb +52 -0
- data/spec/thinking_sphinx/commands/configure_spec.rb +31 -0
- data/spec/thinking_sphinx/commands/index_real_time_spec.rb +33 -0
- data/spec/thinking_sphinx/commands/index_sql_spec.rb +86 -0
- data/spec/thinking_sphinx/commands/merge_and_update_spec.rb +106 -0
- data/spec/thinking_sphinx/commands/merge_spec.rb +48 -0
- data/spec/thinking_sphinx/commands/prepare_spec.rb +31 -0
- data/spec/thinking_sphinx/commands/running_spec.rb +30 -0
- data/spec/thinking_sphinx/commands/start_detached_spec.rb +67 -0
- data/spec/thinking_sphinx/commands/stop_spec.rb +63 -0
- data/spec/thinking_sphinx/configuration/minimum_fields_spec.rb +60 -0
- data/spec/thinking_sphinx/configuration_spec.rb +247 -94
- data/spec/thinking_sphinx/connection/mri_spec.rb +49 -0
- data/spec/thinking_sphinx/connection_spec.rb +15 -13
- data/spec/thinking_sphinx/deletion_spec.rb +17 -17
- data/spec/thinking_sphinx/deltas/default_delta_spec.rb +28 -21
- data/spec/thinking_sphinx/deltas_spec.rb +14 -12
- data/spec/thinking_sphinx/errors_spec.rb +59 -27
- data/spec/thinking_sphinx/excerpter_spec.rb +12 -9
- data/spec/thinking_sphinx/facet_search_spec.rb +24 -22
- data/spec/thinking_sphinx/hooks/guard_presence_spec.rb +30 -0
- data/spec/thinking_sphinx/index_set_spec.rb +59 -18
- data/spec/thinking_sphinx/index_spec.rb +28 -26
- data/spec/thinking_sphinx/interfaces/daemon_spec.rb +60 -0
- data/spec/thinking_sphinx/interfaces/real_time_spec.rb +109 -0
- data/spec/thinking_sphinx/interfaces/sql_spec.rb +122 -0
- data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +22 -20
- data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +20 -18
- data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +45 -21
- data/spec/thinking_sphinx/middlewares/geographer_spec.rb +11 -9
- data/spec/thinking_sphinx/middlewares/glazier_spec.rb +12 -9
- data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +9 -7
- data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +60 -58
- data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +7 -4
- data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +39 -17
- data/spec/thinking_sphinx/middlewares/valid_options_spec.rb +51 -0
- data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +3 -1
- data/spec/thinking_sphinx/panes/distance_pane_spec.rb +6 -4
- data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +8 -6
- data/spec/thinking_sphinx/panes/weight_pane_spec.rb +4 -2
- data/spec/thinking_sphinx/rake_interface_spec.rb +17 -235
- data/spec/thinking_sphinx/real_time/attribute_spec.rb +15 -13
- data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +114 -28
- data/spec/thinking_sphinx/real_time/field_spec.rb +16 -14
- data/spec/thinking_sphinx/real_time/index_spec.rb +83 -32
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +44 -42
- data/spec/thinking_sphinx/real_time/transcribe_instance_spec.rb +35 -0
- data/spec/thinking_sphinx/real_time/transcriber_spec.rb +109 -0
- data/spec/thinking_sphinx/real_time/translator_spec.rb +17 -0
- data/spec/thinking_sphinx/scopes_spec.rb +11 -5
- data/spec/thinking_sphinx/search/glaze_spec.rb +17 -15
- data/spec/thinking_sphinx/search/query_spec.rb +19 -10
- data/spec/thinking_sphinx/search_spec.rb +30 -28
- data/spec/thinking_sphinx/wildcard_spec.rb +18 -11
- data/spec/thinking_sphinx_spec.rb +10 -7
- data/thinking-sphinx.gemspec +17 -10
- metadata +157 -49
- data/HISTORY +0 -248
- data/gemfiles/.gitignore +0 -1
- data/gemfiles/rails_3_2.gemfile +0 -11
- data/gemfiles/rails_4_0.gemfile +0 -11
- data/gemfiles/rails_4_1.gemfile +0 -11
- data/gemfiles/rails_4_2.gemfile +0 -11
- data/lib/thinking_sphinx/controller.rb +0 -10
- data/lib/thinking_sphinx/middlewares/utf8.rb +0 -27
- data/lib/thinking_sphinx/sphinxql.rb +0 -23
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ThinkingSphinx::RealTime::TranscribeInstance
|
|
4
|
+
def self.call(instance, index, properties)
|
|
5
|
+
new(instance, index, properties).call
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def initialize(instance, index, properties)
|
|
9
|
+
@instance, @index, @properties = instance, index, properties
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call
|
|
13
|
+
properties.each_with_object([document_id]) do |property, instance_values|
|
|
14
|
+
begin
|
|
15
|
+
instance_values << property.translate(instance)
|
|
16
|
+
rescue StandardError => error
|
|
17
|
+
raise_wrapper error, property
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
attr_reader :instance, :index, :properties
|
|
25
|
+
|
|
26
|
+
def document_id
|
|
27
|
+
index.document_id_for_key instance.public_send(index.primary_key)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def raise_wrapper(error, property)
|
|
31
|
+
wrapper = ThinkingSphinx::TranscriptionError.new
|
|
32
|
+
wrapper.inner_exception = error
|
|
33
|
+
wrapper.instance = instance
|
|
34
|
+
wrapper.property = property
|
|
35
|
+
|
|
36
|
+
raise wrapper
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::RealTime::Transcriber
|
|
2
4
|
def initialize(index)
|
|
3
5
|
@index = index
|
|
4
6
|
end
|
|
5
7
|
|
|
6
|
-
def
|
|
7
|
-
|
|
8
|
+
def clear_before(time)
|
|
9
|
+
execute <<~SQL.strip
|
|
10
|
+
DELETE FROM #{@index.name} WHERE sphinx_updated_at < #{time.to_i}
|
|
11
|
+
SQL
|
|
12
|
+
end
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
def copy(*instances)
|
|
15
|
+
items = instances.select { |instance|
|
|
16
|
+
instance.persisted? && copy?(instance)
|
|
17
|
+
}
|
|
18
|
+
return unless items.present?
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ThinkingSphinx::Logger.log :query, sphinxql do
|
|
19
|
-
ThinkingSphinx::Connection.take do |connection|
|
|
20
|
-
connection.execute sphinxql
|
|
21
|
-
end
|
|
22
|
-
end
|
|
20
|
+
delete_existing items
|
|
21
|
+
insert_replacements items
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
private
|
|
26
25
|
|
|
27
26
|
attr_reader :index
|
|
28
27
|
|
|
28
|
+
def columns
|
|
29
|
+
@columns ||= properties.each_with_object(['id']) do |property, columns|
|
|
30
|
+
columns << property.name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
29
34
|
def copy?(instance)
|
|
30
35
|
index.conditions.empty? || index.conditions.all? { |condition|
|
|
31
36
|
case condition
|
|
@@ -38,4 +43,47 @@ class ThinkingSphinx::RealTime::Transcriber
|
|
|
38
43
|
end
|
|
39
44
|
}
|
|
40
45
|
end
|
|
46
|
+
|
|
47
|
+
def delete_existing(instances)
|
|
48
|
+
ids = instances.collect(&index.primary_key.to_sym)
|
|
49
|
+
|
|
50
|
+
execute <<~SQL.strip
|
|
51
|
+
DELETE FROM #{@index.name} WHERE sphinx_internal_id IN (#{ids.join(', ')})
|
|
52
|
+
SQL
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def execute(sphinxql)
|
|
56
|
+
ThinkingSphinx::Logger.log :query, sphinxql do
|
|
57
|
+
ThinkingSphinx::Connection.take do |connection|
|
|
58
|
+
connection.execute sphinxql
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def insert_replacements(instances)
|
|
64
|
+
insert = Riddle::Query::Insert.new index.name, columns, values(instances)
|
|
65
|
+
execute insert.replace!.to_sql
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def instrument(message, options = {})
|
|
69
|
+
ActiveSupport::Notifications.instrument(
|
|
70
|
+
"#{message}.thinking_sphinx.real_time", options.merge(:index => index)
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def properties
|
|
75
|
+
@properties ||= index.fields + index.attributes
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def values(instances)
|
|
79
|
+
instances.each_with_object([]) do |instance, array|
|
|
80
|
+
begin
|
|
81
|
+
array << ThinkingSphinx::RealTime::TranscribeInstance.call(
|
|
82
|
+
instance, index, properties
|
|
83
|
+
)
|
|
84
|
+
rescue ThinkingSphinx::TranscriptionError => error
|
|
85
|
+
instrument 'error', :error => error
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
41
89
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ThinkingSphinx::RealTime::Translator
|
|
4
|
+
def self.call(object, column)
|
|
5
|
+
new(object, column).call
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def initialize(object, column)
|
|
9
|
+
@object, @column = object, column
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call
|
|
13
|
+
return name.call(object) if name.is_a?(Proc)
|
|
14
|
+
return name unless name.is_a?(Symbol)
|
|
15
|
+
return result unless result.is_a?(String)
|
|
16
|
+
|
|
17
|
+
result.gsub("\u0000", '').force_encoding "UTF-8"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
attr_reader :object, :column
|
|
23
|
+
|
|
24
|
+
def name
|
|
25
|
+
@column.__name
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def owner
|
|
29
|
+
stack.inject(object) { |previous, node| previous.try node }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def result
|
|
33
|
+
@result ||= owner.try name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def stack
|
|
37
|
+
@column.__stack
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ThinkingSphinx::RealTime
|
|
2
4
|
module Callbacks
|
|
3
5
|
#
|
|
4
6
|
end
|
|
5
7
|
|
|
6
8
|
def self.callback_for(reference, path = [], &block)
|
|
7
|
-
Callbacks::RealTimeCallbacks.new reference, path, &block
|
|
9
|
+
Callbacks::RealTimeCallbacks.new reference.to_sym, path, &block
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.populator
|
|
13
|
+
@populator ||= ThinkingSphinx::RealTime::Populator
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.populator=(value)
|
|
17
|
+
@populator = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.processor
|
|
21
|
+
@processor ||= ThinkingSphinx::RealTime::Processor
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.processor=(value)
|
|
25
|
+
@processor = value
|
|
8
26
|
end
|
|
9
27
|
end
|
|
10
28
|
|
|
@@ -14,6 +32,9 @@ require 'thinking_sphinx/real_time/field'
|
|
|
14
32
|
require 'thinking_sphinx/real_time/index'
|
|
15
33
|
require 'thinking_sphinx/real_time/interpreter'
|
|
16
34
|
require 'thinking_sphinx/real_time/populator'
|
|
35
|
+
require 'thinking_sphinx/real_time/processor'
|
|
36
|
+
require 'thinking_sphinx/real_time/transcribe_instance'
|
|
17
37
|
require 'thinking_sphinx/real_time/transcriber'
|
|
38
|
+
require 'thinking_sphinx/real_time/translator'
|
|
18
39
|
|
|
19
40
|
require 'thinking_sphinx/real_time/callbacks/real_time_callbacks'
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ThinkingSphinx::Scopes
|
|
2
4
|
extend ActiveSupport::Concern
|
|
3
5
|
|
|
@@ -24,5 +26,9 @@ module ThinkingSphinx::Scopes
|
|
|
24
26
|
query, options = sphinx_scopes[method].call(*args)
|
|
25
27
|
search query, (options || {})
|
|
26
28
|
end
|
|
29
|
+
|
|
30
|
+
def respond_to_missing?(method, include_private = false)
|
|
31
|
+
super || sphinx_scopes.keys.include?(method)
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
34
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Search::Context
|
|
2
4
|
attr_reader :search, :configuration
|
|
3
5
|
|
|
@@ -5,6 +7,7 @@ class ThinkingSphinx::Search::Context
|
|
|
5
7
|
@search = search
|
|
6
8
|
@configuration = configuration || ThinkingSphinx::Configuration.instance
|
|
7
9
|
@memory = {
|
|
10
|
+
:raw => [],
|
|
8
11
|
:results => [],
|
|
9
12
|
:panes => ThinkingSphinx::Configuration::Defaults::PANES.clone
|
|
10
13
|
}
|
|
@@ -17,4 +20,12 @@ class ThinkingSphinx::Search::Context
|
|
|
17
20
|
def []=(key, value)
|
|
18
21
|
@memory[key] = value
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
def marshal_dump
|
|
25
|
+
[@memory.except(:raw, :indices)]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def marshal_load(array)
|
|
29
|
+
@memory = array.first
|
|
30
|
+
end
|
|
20
31
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
class ThinkingSphinx::Search::Query
|
|
3
5
|
attr_reader :keywords, :conditions, :star
|
|
4
6
|
|
|
@@ -10,12 +12,18 @@ class ThinkingSphinx::Search::Query
|
|
|
10
12
|
(star_keyword(keywords || '') + ' ' + conditions.keys.collect { |key|
|
|
11
13
|
next if conditions[key].blank?
|
|
12
14
|
|
|
13
|
-
"
|
|
15
|
+
"#{expand_key key} #{star_keyword conditions[key], key}"
|
|
14
16
|
}.join(' ')).strip
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
|
18
20
|
|
|
21
|
+
def expand_key(key)
|
|
22
|
+
return "@#{key}" unless key.is_a?(Array)
|
|
23
|
+
|
|
24
|
+
"@(#{key.join(',')})"
|
|
25
|
+
end
|
|
26
|
+
|
|
19
27
|
def star_keyword(keyword, key = nil)
|
|
20
28
|
return keyword.to_s unless star
|
|
21
29
|
return keyword.to_s if key.to_s == 'sphinx_internal_class_name'
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Search::StaleIdsException < StandardError
|
|
2
|
-
attr_reader :ids
|
|
4
|
+
attr_reader :ids, :context
|
|
3
5
|
|
|
4
|
-
def initialize(ids)
|
|
6
|
+
def initialize(ids, context)
|
|
5
7
|
@ids = ids
|
|
8
|
+
@context = context
|
|
6
9
|
end
|
|
7
10
|
|
|
8
11
|
def message
|
|
9
|
-
"Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}"
|
|
12
|
+
"Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}\n" \
|
|
13
|
+
"https://freelancing-gods.com/thinking-sphinx/v5/common_issues.html#record-ids"
|
|
10
14
|
end
|
|
11
15
|
end
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Search < Array
|
|
2
4
|
CORE_METHODS = %w( == class class_eval extend frozen? id instance_eval
|
|
3
|
-
instance_of? instance_values instance_variable_defined?
|
|
5
|
+
instance_exec instance_of? instance_values instance_variable_defined?
|
|
4
6
|
instance_variable_get instance_variable_set instance_variables is_a?
|
|
5
7
|
kind_of? member? method methods nil? object_id respond_to?
|
|
6
8
|
respond_to_missing? send should should_not type )
|
|
7
9
|
SAFE_METHODS = %w( partition private_methods protected_methods public_methods
|
|
8
10
|
send class )
|
|
11
|
+
KNOWN_OPTIONS = (
|
|
12
|
+
[
|
|
13
|
+
:classes, :conditions, :excerpts, :geo, :group_by, :ids_only,
|
|
14
|
+
:ignore_scopes, :indices, :limit, :masks, :max_matches, :middleware,
|
|
15
|
+
:none, :offset, :order, :order_group_by, :page, :per_page, :populate,
|
|
16
|
+
:retry_stale, :select, :skip_sti, :sql, :star, :with, :with_all, :without,
|
|
17
|
+
:without_ids
|
|
18
|
+
] +
|
|
19
|
+
ThinkingSphinx::Middlewares::SphinxQL::SELECT_OPTIONS
|
|
20
|
+
).uniq
|
|
9
21
|
DEFAULT_MASKS = [
|
|
10
22
|
ThinkingSphinx::Masks::PaginationMask,
|
|
11
23
|
ThinkingSphinx::Masks::ScopesMask,
|
|
@@ -21,6 +33,12 @@ class ThinkingSphinx::Search < Array
|
|
|
21
33
|
attr_reader :options
|
|
22
34
|
attr_accessor :query
|
|
23
35
|
|
|
36
|
+
def self.valid_options
|
|
37
|
+
@valid_options
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@valid_options = KNOWN_OPTIONS.dup
|
|
41
|
+
|
|
24
42
|
def initialize(query = nil, options = {})
|
|
25
43
|
query, options = nil, query if query.is_a?(Hash)
|
|
26
44
|
@query, @options = query, options
|
|
@@ -38,6 +56,16 @@ class ThinkingSphinx::Search < Array
|
|
|
38
56
|
options[:page].to_i
|
|
39
57
|
end
|
|
40
58
|
|
|
59
|
+
def marshal_dump
|
|
60
|
+
populate
|
|
61
|
+
|
|
62
|
+
[@populated, @query, @options, @context]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def marshal_load(array)
|
|
66
|
+
@populated, @query, @options, @context = array
|
|
67
|
+
end
|
|
68
|
+
|
|
41
69
|
def masks
|
|
42
70
|
@masks ||= @options[:masks] || DEFAULT_MASKS.clone
|
|
43
71
|
end
|
|
@@ -64,7 +92,7 @@ class ThinkingSphinx::Search < Array
|
|
|
64
92
|
def populate
|
|
65
93
|
return self if @populated
|
|
66
94
|
|
|
67
|
-
middleware.call [context]
|
|
95
|
+
middleware.call [context] unless options[:none]
|
|
68
96
|
@populated = true
|
|
69
97
|
|
|
70
98
|
self
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pathname"
|
|
4
|
+
|
|
5
|
+
class ThinkingSphinx::Settings
|
|
6
|
+
ALWAYS_ABSOLUTE = %w[ socket ]
|
|
7
|
+
FILE_KEYS = %w[
|
|
8
|
+
indices_location configuration_file bin_path log query_log pid_file
|
|
9
|
+
binlog_path snippets_file_prefix sphinxql_state path stopwords wordforms
|
|
10
|
+
exceptions global_idf rlp_context rlp_root rlp_environment plugin_dir
|
|
11
|
+
lemmatizer_base mysql_ssl_cert mysql_ssl_key mysql_ssl_ca
|
|
12
|
+
].freeze
|
|
13
|
+
DEFAULTS = {
|
|
14
|
+
"configuration_file" => "config/ENVIRONMENT.sphinx.conf",
|
|
15
|
+
"indices_location" => "db/sphinx/ENVIRONMENT",
|
|
16
|
+
"pid_file" => "log/ENVIRONMENT.sphinx.pid",
|
|
17
|
+
"log" => "log/ENVIRONMENT.searchd.log",
|
|
18
|
+
"query_log" => "log/ENVIRONMENT.searchd.query.log",
|
|
19
|
+
"binlog_path" => "tmp/binlog/ENVIRONMENT",
|
|
20
|
+
"workers" => "threads",
|
|
21
|
+
"mysql_encoding" => "utf8",
|
|
22
|
+
"maximum_statement_length" => (2 ** 23) - 5,
|
|
23
|
+
"real_time_tidy" => false,
|
|
24
|
+
"cutoff" => 0
|
|
25
|
+
}.freeze
|
|
26
|
+
YAML_SAFE_LOAD = YAML.method(:safe_load).parameters.any? do |parameter|
|
|
27
|
+
parameter == [:key, :aliases]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.call(configuration)
|
|
31
|
+
new(configuration).call
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def initialize(configuration)
|
|
35
|
+
@configuration = configuration
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def call
|
|
39
|
+
return defaults unless File.exist? file
|
|
40
|
+
|
|
41
|
+
merged.inject({}) do |hash, (key, value)|
|
|
42
|
+
if absolute_key?(key)
|
|
43
|
+
hash[key] = absolute value
|
|
44
|
+
else
|
|
45
|
+
hash[key] = value
|
|
46
|
+
end
|
|
47
|
+
hash
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
attr_reader :configuration
|
|
54
|
+
|
|
55
|
+
delegate :framework, :to => :configuration
|
|
56
|
+
|
|
57
|
+
def absolute(relative)
|
|
58
|
+
return relative if relative.nil?
|
|
59
|
+
|
|
60
|
+
real_path File.absolute_path(relative, framework.root)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def absolute_key?(key)
|
|
64
|
+
return true if ALWAYS_ABSOLUTE.include?(key)
|
|
65
|
+
|
|
66
|
+
merged["absolute_paths"] && file_keys.include?(key)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def defaults
|
|
70
|
+
DEFAULTS.inject({}) do |hash, (key, value)|
|
|
71
|
+
if value.is_a?(String)
|
|
72
|
+
value = value.gsub("ENVIRONMENT", framework.environment)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
if FILE_KEYS.include?(key)
|
|
76
|
+
hash[key] = absolute value
|
|
77
|
+
else
|
|
78
|
+
hash[key] = value
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
hash
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def file
|
|
86
|
+
@file ||= Pathname.new(framework.root).join "config", "thinking_sphinx.yml"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def file_keys
|
|
90
|
+
@file_keys ||= FILE_KEYS + (original["file_keys"] || [])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def join(first, last)
|
|
94
|
+
return first if last.nil?
|
|
95
|
+
|
|
96
|
+
File.join first, last
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def merged
|
|
100
|
+
@merged ||= defaults.merge original
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def original
|
|
104
|
+
yaml_contents && yaml_contents[framework.environment] || {}
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def real_path(base, nonexistent = nil)
|
|
108
|
+
if File.exist?(base)
|
|
109
|
+
join File.realpath(base), nonexistent
|
|
110
|
+
else
|
|
111
|
+
components = File.split base
|
|
112
|
+
real_path components.first, join(components.last, nonexistent)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def yaml_contents
|
|
117
|
+
@yaml_contents ||= begin
|
|
118
|
+
input = File.read file
|
|
119
|
+
input = ERB.new(input).result if defined?(ERB)
|
|
120
|
+
|
|
121
|
+
if YAML_SAFE_LOAD
|
|
122
|
+
YAML.safe_load(input, aliases: true)
|
|
123
|
+
else
|
|
124
|
+
YAML.load(input)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Subscribers::PopulatorSubscriber
|
|
2
4
|
def self.attach_to(namespace)
|
|
3
5
|
subscriber = new
|
|
@@ -16,19 +18,31 @@ class ThinkingSphinx::Subscribers::PopulatorSubscriber
|
|
|
16
18
|
ActiveSupport::Notifications::Event.new(message, *args)
|
|
17
19
|
end
|
|
18
20
|
|
|
21
|
+
def error(event)
|
|
22
|
+
error = event.payload[:error].inner_exception
|
|
23
|
+
instance = event.payload[:error].instance
|
|
24
|
+
|
|
25
|
+
puts <<-MESSAGE
|
|
26
|
+
|
|
27
|
+
Error transcribing #{instance.class} #{instance.id}:
|
|
28
|
+
#{error.message}
|
|
29
|
+
MESSAGE
|
|
30
|
+
end
|
|
31
|
+
|
|
19
32
|
def start_populating(event)
|
|
20
33
|
puts "Generating index files for #{event.payload[:index].name}"
|
|
21
34
|
end
|
|
22
35
|
|
|
23
36
|
def populated(event)
|
|
24
|
-
print '.'
|
|
37
|
+
print '.' * event.payload[:instances].length
|
|
25
38
|
end
|
|
26
39
|
|
|
27
40
|
def finish_populating(event)
|
|
28
41
|
print "\n"
|
|
29
42
|
end
|
|
30
|
-
end
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
delegate :output, :to => ThinkingSphinx
|
|
47
|
+
delegate :puts, :print, :to => :output
|
|
48
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
namespace :ts do
|
|
2
4
|
desc 'Generate the Sphinx configuration file'
|
|
3
5
|
task :configure => :environment do
|
|
@@ -5,54 +7,79 @@ namespace :ts do
|
|
|
5
7
|
end
|
|
6
8
|
|
|
7
9
|
desc 'Generate the Sphinx configuration file and process all indices'
|
|
8
|
-
task :index => :
|
|
9
|
-
interface.index(
|
|
10
|
-
ENV['INDEX_ONLY'] != 'true',
|
|
11
|
-
!Rake.application.options.silent
|
|
12
|
-
)
|
|
13
|
-
end
|
|
10
|
+
task :index => ['ts:sql:index', 'ts:rt:index']
|
|
14
11
|
|
|
15
12
|
desc 'Clear out Sphinx files'
|
|
16
|
-
task :clear => :
|
|
17
|
-
interface.clear_all
|
|
18
|
-
end
|
|
13
|
+
task :clear => ['ts:sql:clear', 'ts:rt:clear']
|
|
19
14
|
|
|
20
|
-
desc
|
|
21
|
-
task :
|
|
22
|
-
interface.clear_real_time
|
|
23
|
-
end
|
|
15
|
+
desc "Merge all delta indices into their respective core indices"
|
|
16
|
+
task :merge => ["ts:sql:merge"]
|
|
24
17
|
|
|
25
|
-
desc '
|
|
26
|
-
task :
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
desc 'Stop Sphinx, index and then restart Sphinx'
|
|
32
|
-
task :rebuild => [:stop, :clear, :index, :start]
|
|
33
|
-
|
|
34
|
-
desc 'Stop Sphinx, clear files, reconfigure, start Sphinx, generate files'
|
|
35
|
-
task :regenerate => [:stop, :clear_rt, :configure, :start, :generate]
|
|
18
|
+
desc 'Delete and regenerate Sphinx files, restart the daemon'
|
|
19
|
+
task :rebuild => [
|
|
20
|
+
:stop, :clear, :configure, 'ts:sql:index', :start, 'ts:rt:index'
|
|
21
|
+
]
|
|
36
22
|
|
|
37
23
|
desc 'Restart the Sphinx daemon'
|
|
38
24
|
task :restart => [:stop, :start]
|
|
39
25
|
|
|
40
26
|
desc 'Start the Sphinx daemon'
|
|
41
27
|
task :start => :environment do
|
|
42
|
-
interface.start
|
|
28
|
+
interface.daemon.start
|
|
43
29
|
end
|
|
44
30
|
|
|
45
31
|
desc 'Stop the Sphinx daemon'
|
|
46
32
|
task :stop => :environment do
|
|
47
|
-
interface.stop
|
|
33
|
+
interface.daemon.stop
|
|
48
34
|
end
|
|
49
35
|
|
|
50
36
|
desc 'Determine whether Sphinx is running'
|
|
51
37
|
task :status => :environment do
|
|
52
|
-
interface.status
|
|
38
|
+
interface.daemon.status
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
namespace :sql do
|
|
42
|
+
desc 'Delete SQL-backed Sphinx files'
|
|
43
|
+
task :clear => :environment do
|
|
44
|
+
interface.sql.clear
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc 'Generate fresh index files for SQL-backed indices'
|
|
48
|
+
task :index => :environment do
|
|
49
|
+
interface.sql.index(ENV['INDEX_ONLY'] != 'true')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :merge => :environment do
|
|
53
|
+
interface.sql.merge
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
desc 'Delete and regenerate SQL-backed Sphinx files, restart the daemon'
|
|
57
|
+
task :rebuild => ['ts:stop', 'ts:sql:clear', 'ts:sql:index', 'ts:start']
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
namespace :rt do
|
|
61
|
+
desc 'Delete real-time Sphinx files'
|
|
62
|
+
task :clear => :environment do
|
|
63
|
+
interface.rt.clear
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
desc 'Generate fresh index files for real-time indices'
|
|
67
|
+
task :index => :environment do
|
|
68
|
+
interface.rt.index
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
desc 'Delete and regenerate real-time Sphinx files, restart the daemon'
|
|
72
|
+
task :rebuild => [
|
|
73
|
+
'ts:stop', 'ts:rt:clear', 'ts:configure', 'ts:start', 'ts:rt:index'
|
|
74
|
+
]
|
|
53
75
|
end
|
|
54
76
|
|
|
55
77
|
def interface
|
|
56
|
-
@interface ||= ThinkingSphinx
|
|
78
|
+
@interface ||= ThinkingSphinx.rake_interface.new(
|
|
79
|
+
:verbose => Rake::FileUtilsExt.verbose_flag,
|
|
80
|
+
:silent => Rake.application.options.silent,
|
|
81
|
+
:nodetach => (ENV['NODETACH'] == 'true'),
|
|
82
|
+
:index_names => ENV.fetch('INDEX_FILTER', '').split(',')
|
|
83
|
+
)
|
|
57
84
|
end
|
|
58
85
|
end
|