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
|
@@ -1,16 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SphinxHelpers
|
|
2
4
|
def sphinx
|
|
3
5
|
@sphinx ||= SphinxController.new
|
|
4
6
|
end
|
|
5
7
|
|
|
6
8
|
def index(*indices)
|
|
7
|
-
sleep 0.5 if ENV['
|
|
9
|
+
sleep 0.5 if ENV['CI']
|
|
8
10
|
|
|
9
11
|
yield if block_given?
|
|
10
12
|
|
|
11
13
|
sphinx.index *indices
|
|
12
14
|
sleep 0.25
|
|
13
|
-
sleep 0.5 if ENV['
|
|
15
|
+
sleep 0.5 if ENV['CI']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def merge
|
|
19
|
+
sleep 0.5 if ENV['CI']
|
|
20
|
+
sleep 0.5
|
|
21
|
+
|
|
22
|
+
sphinx.merge
|
|
23
|
+
sleep 1.5
|
|
24
|
+
sleep 0.5 if ENV['CI']
|
|
14
25
|
end
|
|
15
26
|
end
|
|
16
27
|
|
|
@@ -27,4 +38,8 @@ RSpec.configure do |config|
|
|
|
27
38
|
config.after :all do |group|
|
|
28
39
|
sphinx.stop if group.class.metadata[:live]
|
|
29
40
|
end
|
|
41
|
+
|
|
42
|
+
config.after :suite do
|
|
43
|
+
SphinxController.new.stop
|
|
44
|
+
end
|
|
30
45
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Suspend deltas for a given action', :live => true do
|
|
@@ -5,50 +7,50 @@ describe 'Suspend deltas for a given action', :live => true do
|
|
|
5
7
|
book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
|
|
6
8
|
index
|
|
7
9
|
|
|
8
|
-
Book.search('Harry').to_a.
|
|
10
|
+
expect(Book.search('Harry').to_a).to eq([book])
|
|
9
11
|
|
|
10
12
|
ThinkingSphinx::Deltas.suspend :book do
|
|
11
|
-
book.reload.
|
|
13
|
+
book.reload.update(:author => 'Terry Pratchett')
|
|
12
14
|
sleep 0.25
|
|
13
15
|
|
|
14
|
-
Book.search('Terry').to_a.
|
|
16
|
+
expect(Book.search('Terry').to_a).to eq([])
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
sleep 0.25
|
|
18
|
-
Book.search('Terry').to_a.
|
|
20
|
+
expect(Book.search('Terry').to_a).to eq([book])
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it "returns core records even though they are no longer valid" do
|
|
22
24
|
book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
|
|
23
25
|
index
|
|
24
26
|
|
|
25
|
-
Book.search('Harry').to_a.
|
|
27
|
+
expect(Book.search('Harry').to_a).to eq([book])
|
|
26
28
|
|
|
27
29
|
ThinkingSphinx::Deltas.suspend :book do
|
|
28
|
-
book.reload.
|
|
30
|
+
book.reload.update(:author => 'Terry Pratchett')
|
|
29
31
|
sleep 0.25
|
|
30
32
|
|
|
31
|
-
Book.search('Terry').to_a.
|
|
33
|
+
expect(Book.search('Terry').to_a).to eq([])
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
sleep 0.25
|
|
35
|
-
Book.search('Harry').to_a.
|
|
37
|
+
expect(Book.search('Harry').to_a).to eq([book])
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
it "marks core records as deleted" do
|
|
39
41
|
book = Book.create :title => 'Night Watch', :author => 'Harry Pritchett'
|
|
40
42
|
index
|
|
41
43
|
|
|
42
|
-
Book.search('Harry').to_a.
|
|
44
|
+
expect(Book.search('Harry').to_a).to eq([book])
|
|
43
45
|
|
|
44
46
|
ThinkingSphinx::Deltas.suspend_and_update :book do
|
|
45
|
-
book.reload.
|
|
47
|
+
book.reload.update(:author => 'Terry Pratchett')
|
|
46
48
|
sleep 0.25
|
|
47
49
|
|
|
48
|
-
Book.search('Terry').to_a.
|
|
50
|
+
expect(Book.search('Terry').to_a).to eq([])
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
sleep 0.25
|
|
52
|
-
Book.search('Harry').to_a.
|
|
54
|
+
expect(Book.search('Harry').to_a).to be_empty
|
|
53
55
|
end
|
|
54
56
|
end
|
data/spec/fixtures/database.yml
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
ThinkingSphinx::Index.define :album, :with => :active_record, :primary_key => :integer_id, :delta => true do
|
|
4
|
+
indexes name, artist
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
ThinkingSphinx::Index.define :album, :with => :real_time, :primary_key => :integer_id, :name => :album_real do
|
|
8
|
+
indexes name, artist
|
|
9
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
ThinkingSphinx::Index.define :article, :with => :active_record do
|
|
2
4
|
indexes title, content
|
|
3
5
|
indexes user.name, :as => :user
|
|
@@ -5,10 +7,9 @@ ThinkingSphinx::Index.define :article, :with => :active_record do
|
|
|
5
7
|
|
|
6
8
|
has published, user_id
|
|
7
9
|
has taggings.tag_id, :as => :tag_ids, :source => :query
|
|
8
|
-
has taggings.created_at, :as => :taggings_at
|
|
10
|
+
has taggings.created_at, :as => :taggings_at, :type => :timestamp
|
|
9
11
|
|
|
10
12
|
set_property :min_infix_len => 4
|
|
11
|
-
set_property :enable_star => true
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
ThinkingSphinx::Index.define :article, :with => :active_record,
|
|
@@ -18,7 +19,13 @@ ThinkingSphinx::Index.define :article, :with => :active_record,
|
|
|
18
19
|
|
|
19
20
|
has published, user_id
|
|
20
21
|
has taggings.tag_id, :as => :tag_ids
|
|
21
|
-
has taggings.created_at, :as => :taggings_at
|
|
22
|
+
has taggings.created_at, :as => :taggings_at, :type => :timestamp
|
|
22
23
|
|
|
23
24
|
set_property :morphology => 'stem_en'
|
|
24
25
|
end
|
|
26
|
+
|
|
27
|
+
ThinkingSphinx::Index.define :article, :name => :published_articles, :with => :real_time do
|
|
28
|
+
indexes title, content
|
|
29
|
+
|
|
30
|
+
scope { Article.where :published => true }
|
|
31
|
+
end
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
ThinkingSphinx::Index.define :book, :with => :active_record, :delta => true do
|
|
2
4
|
indexes title, :sortable => true
|
|
3
5
|
indexes author, :facet => true
|
|
4
6
|
indexes [title, author], :as => :info
|
|
5
7
|
indexes blurb_file, :file => true
|
|
6
8
|
|
|
7
|
-
has
|
|
9
|
+
has publishing_year
|
|
10
|
+
has created_at, :type => :timestamp
|
|
8
11
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
multi_schema = MultiSchema.new
|
|
2
4
|
|
|
3
5
|
ThinkingSphinx::Index.define :product, :with => :real_time do
|
|
4
6
|
indexes name, :sortable => true
|
|
5
7
|
|
|
6
8
|
has category_ids, :type => :integer, :multi => true
|
|
9
|
+
has options, :type => :json if JSONColumn.call
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
if multi_schema.active?
|
|
10
|
-
multi_schema.create 'thinking_sphinx'
|
|
11
|
-
|
|
12
13
|
ThinkingSphinx::Index.define(:product,
|
|
13
14
|
:name => :product_two, :offset_as => :product_two, :with => :real_time
|
|
14
15
|
) do
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Album < ActiveRecord::Base
|
|
4
|
+
self.primary_key = :id
|
|
5
|
+
|
|
6
|
+
before_validation :set_id, :on => :create
|
|
7
|
+
before_validation :set_integer_id, :on => :create
|
|
8
|
+
|
|
9
|
+
ThinkingSphinx::Callbacks.append(
|
|
10
|
+
self, :behaviours => [:sql, :real_time, :deltas]
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
validates :id, :presence => true, :uniqueness => true
|
|
14
|
+
validates :integer_id, :presence => true, :uniqueness => true
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def set_id
|
|
19
|
+
self.id = (Album.maximum(:id) || "a").next
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def set_integer_id
|
|
23
|
+
self.integer_id = (Album.maximum(:integer_id) || 0) + 1
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Book < ActiveRecord::Base
|
|
2
4
|
include ThinkingSphinx::Scopes
|
|
3
5
|
|
|
4
6
|
has_and_belongs_to_many :genres
|
|
5
7
|
|
|
8
|
+
ThinkingSphinx::Callbacks.append(self, :behaviours => [:sql, :deltas])
|
|
9
|
+
|
|
6
10
|
sphinx_scope(:by_query) { |query| query }
|
|
7
|
-
sphinx_scope(:
|
|
8
|
-
{:with => {:
|
|
11
|
+
sphinx_scope(:by_publishing_year) do |year|
|
|
12
|
+
{:with => {:publishing_year => year}}
|
|
9
13
|
end
|
|
10
|
-
sphinx_scope(:
|
|
11
|
-
[query, {:with => {:
|
|
14
|
+
sphinx_scope(:by_query_and_publishing_year) do |query, year|
|
|
15
|
+
[query, {:with => {:publishing_year =>year}}]
|
|
12
16
|
end
|
|
13
|
-
sphinx_scope(:ordered) { {:order => '
|
|
17
|
+
sphinx_scope(:ordered) { {:order => 'publishing_year DESC'} }
|
|
14
18
|
end
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Categorisation < ActiveRecord::Base
|
|
2
4
|
belongs_to :category
|
|
3
5
|
belongs_to :product
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
after_commit :update_product
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def update_product
|
|
12
|
+
product.reload
|
|
13
|
+
ThinkingSphinx::RealTime.callback_for(:product, [:product]).after_save self
|
|
14
|
+
end
|
|
6
15
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class Product < ActiveRecord::Base
|
|
2
4
|
has_many :categorisations
|
|
3
5
|
has_many :categories, :through => :categorisations
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
ThinkingSphinx::Callbacks.append(self, :behaviours => [:real_time])
|
|
6
8
|
end
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
test:
|
|
2
2
|
adapter: <%= ENV['DATABASE'] || 'mysql2' %>
|
|
3
3
|
database: thinking_sphinx
|
|
4
|
-
username: <%= ENV['DATABASE'] == 'postgresql' ?
|
|
4
|
+
username: <%= ENV['DATABASE'] == 'postgresql' ? 'postgres' : 'root' %>
|
|
5
|
+
<% if ENV["DATABASE_PASSWORD"] %>
|
|
6
|
+
password: <%= ENV["DATABASE_PASSWORD"] %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if ENV["DATABASE_PORT"] %>
|
|
9
|
+
host: 127.0.0.1
|
|
10
|
+
port: <%= ENV["DATABASE_PORT"] %>
|
|
11
|
+
<% elsif ENV["CI"] %>
|
|
12
|
+
password: thinking_sphinx
|
|
13
|
+
host: 127.0.0.1
|
|
14
|
+
port: <%= ENV['DATABASE'] == 'postgresql' ? 5432 : 3306 %>
|
|
15
|
+
<% end %>
|
|
5
16
|
min_messages: warning
|
|
6
17
|
encoding: utf8
|
data/spec/internal/db/schema.rb
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
ActiveRecord::Schema.define do
|
|
2
4
|
create_table(:admin_people, :force => true) do |t|
|
|
3
5
|
t.string :name
|
|
4
6
|
t.timestamps null: false
|
|
5
7
|
end
|
|
6
8
|
|
|
9
|
+
create_table(:albums, :force => true, :id => false) do |t|
|
|
10
|
+
t.string :id
|
|
11
|
+
t.integer :integer_id
|
|
12
|
+
t.string :name
|
|
13
|
+
t.string :artist
|
|
14
|
+
t.boolean :delta, :default => true, :null => false
|
|
15
|
+
end
|
|
16
|
+
|
|
7
17
|
create_table(:animals, :force => true) do |t|
|
|
8
18
|
t.string :name
|
|
9
19
|
t.string :type
|
|
@@ -29,7 +39,7 @@ ActiveRecord::Schema.define do
|
|
|
29
39
|
create_table(:books, :force => true) do |t|
|
|
30
40
|
t.string :title
|
|
31
41
|
t.string :author
|
|
32
|
-
t.integer :
|
|
42
|
+
t.integer :publishing_year
|
|
33
43
|
t.string :blurb_file
|
|
34
44
|
t.boolean :delta, :default => true, :null => false
|
|
35
45
|
t.string :type, :default => 'Book', :null => false
|
|
@@ -58,6 +68,7 @@ ActiveRecord::Schema.define do
|
|
|
58
68
|
|
|
59
69
|
create_table(:colours, :force => true) do |t|
|
|
60
70
|
t.string :name
|
|
71
|
+
t.boolean :delta, :null => false, :default => true
|
|
61
72
|
t.timestamps null: false
|
|
62
73
|
end
|
|
63
74
|
|
|
@@ -72,6 +83,7 @@ ActiveRecord::Schema.define do
|
|
|
72
83
|
|
|
73
84
|
create_table(:products, :force => true) do |t|
|
|
74
85
|
t.string :name
|
|
86
|
+
t.json :options if ::JSONColumn.call
|
|
75
87
|
end
|
|
76
88
|
|
|
77
89
|
create_table(:taggings, :force => true) do |t|
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rubygems'
|
|
2
4
|
require 'bundler'
|
|
5
|
+
require 'logger'
|
|
3
6
|
|
|
4
7
|
Bundler.require :default, :development
|
|
5
8
|
|
|
6
9
|
root = File.expand_path File.dirname(__FILE__)
|
|
7
10
|
require "#{root}/support/multi_schema"
|
|
11
|
+
require "#{root}/support/json_column"
|
|
12
|
+
require "#{root}/support/mysql"
|
|
8
13
|
require 'thinking_sphinx/railtie'
|
|
9
14
|
|
|
10
15
|
Combustion.initialize! :active_record
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
MultiSchema.new.create 'thinking_sphinx'
|
|
18
|
+
|
|
19
|
+
require "#{root}/support/sphinx_yaml_helpers"
|
|
13
20
|
|
|
14
21
|
RSpec.configure do |config|
|
|
15
22
|
# enable filtering for examples
|
|
16
23
|
config.filter_run :wip => nil
|
|
17
24
|
config.run_all_when_everything_filtered = true
|
|
25
|
+
|
|
26
|
+
config.around :each, :live do |example|
|
|
27
|
+
example.run_with_retry :retry => 3
|
|
28
|
+
end
|
|
18
29
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class JSONColumn
|
|
4
|
+
include ActiveRecord::ConnectionAdapters
|
|
5
|
+
|
|
6
|
+
def self.call
|
|
7
|
+
new.call
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call
|
|
11
|
+
ruby? && postgresql? && column?
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def column?
|
|
17
|
+
(
|
|
18
|
+
ActiveRecord::ConnectionAdapters.constants.include?(:PostgreSQLAdapter) &&
|
|
19
|
+
PostgreSQLAdapter.constants.include?(:TableDefinition) &&
|
|
20
|
+
PostgreSQLAdapter::TableDefinition.instance_methods.include?(:json)
|
|
21
|
+
) || (
|
|
22
|
+
ActiveRecord::ConnectionAdapters.constants.include?(:PostgreSQL) &&
|
|
23
|
+
PostgreSQL.constants.include?(:ColumnMethods) &&
|
|
24
|
+
PostgreSQL::ColumnMethods.instance_methods.include?(:json)
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def postgresql?
|
|
29
|
+
ENV['DATABASE'] == 'postgresql'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def ruby?
|
|
33
|
+
RUBY_PLATFORM != 'java'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class MultiSchema
|
|
2
4
|
def active?
|
|
3
5
|
ENV['DATABASE'] == 'postgresql'
|
|
4
6
|
end
|
|
5
7
|
|
|
6
8
|
def create(schema_name)
|
|
9
|
+
return unless active?
|
|
10
|
+
|
|
7
11
|
unless connection.schema_exists? schema_name
|
|
8
12
|
connection.execute %Q{CREATE SCHEMA "#{schema_name}"}
|
|
9
13
|
end
|
|
10
14
|
|
|
11
15
|
switch schema_name
|
|
12
|
-
|
|
16
|
+
load Rails.root.join('db', 'schema.rb')
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
def current
|