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,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::FacetSearch do
|
|
@@ -25,19 +27,19 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
25
27
|
DumbSearch = ::Struct.new(:query, :options) do
|
|
26
28
|
def raw
|
|
27
29
|
[{
|
|
28
|
-
'sphinx_internal_class'
|
|
29
|
-
'price_bracket'
|
|
30
|
-
'tag_ids'
|
|
31
|
-
'category_id'
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
'sphinx_internal_class' => 'Foo',
|
|
31
|
+
'price_bracket' => 3,
|
|
32
|
+
'tag_ids' => '1,2',
|
|
33
|
+
'category_id' => 11,
|
|
34
|
+
"sphinx_internal_count" => 5,
|
|
35
|
+
"sphinx_internal_group" => 2
|
|
34
36
|
}]
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
describe '#[]' do
|
|
39
41
|
it "populates facet results" do
|
|
40
|
-
facet_search[:price_bracket].
|
|
42
|
+
expect(facet_search[:price_bracket]).to eq({3 => 5})
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
@@ -45,17 +47,17 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
45
47
|
it "queries on each facet with a grouped search in a batch" do
|
|
46
48
|
facet_search.populate
|
|
47
49
|
|
|
48
|
-
batch.searches.detect { |search|
|
|
50
|
+
expect(batch.searches.detect { |search|
|
|
49
51
|
search.options[:group_by] == 'price_bracket'
|
|
50
|
-
}.
|
|
52
|
+
}).not_to be_nil
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
it "limits query for a facet to just indices that have that facet" do
|
|
54
56
|
facet_search.populate
|
|
55
57
|
|
|
56
|
-
batch.searches.detect { |search|
|
|
58
|
+
expect(batch.searches.detect { |search|
|
|
57
59
|
search.options[:indices] == ['foo_core']
|
|
58
|
-
}.
|
|
60
|
+
}).not_to be_nil
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
it "limits facets to the specified set" do
|
|
@@ -63,25 +65,25 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
63
65
|
|
|
64
66
|
facet_search.populate
|
|
65
67
|
|
|
66
|
-
batch.searches.collect { |search|
|
|
68
|
+
expect(batch.searches.collect { |search|
|
|
67
69
|
search.options[:group_by]
|
|
68
|
-
}.
|
|
70
|
+
}).to eq(['category_id'])
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
it "aliases the class facet from sphinx_internal_class" do
|
|
72
|
-
property_a.
|
|
74
|
+
allow(property_a).to receive_messages :name => 'sphinx_internal_class'
|
|
73
75
|
|
|
74
76
|
facet_search.populate
|
|
75
77
|
|
|
76
|
-
facet_search[:class].
|
|
78
|
+
expect(facet_search[:class]).to eq({'Foo' => 5})
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
it "uses the @groupby value for MVAs" do
|
|
80
|
-
property_a.
|
|
82
|
+
allow(property_a).to receive_messages :name => 'tag_ids', :multi? => true
|
|
81
83
|
|
|
82
84
|
facet_search.populate
|
|
83
85
|
|
|
84
|
-
facet_search[:tag_ids].
|
|
86
|
+
expect(facet_search[:tag_ids]).to eq({2 => 5})
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
[:max_matches, :limit].each do |setting|
|
|
@@ -89,7 +91,7 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
89
91
|
facet_search.populate
|
|
90
92
|
|
|
91
93
|
batch.searches.each { |search|
|
|
92
|
-
search.options[setting].
|
|
94
|
+
expect(search.options[setting]).to eq(1000)
|
|
93
95
|
}
|
|
94
96
|
end
|
|
95
97
|
|
|
@@ -99,7 +101,7 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
99
101
|
facet_search.populate
|
|
100
102
|
|
|
101
103
|
batch.searches.each { |search|
|
|
102
|
-
search.options[setting].
|
|
104
|
+
expect(search.options[setting]).to eq(1234)
|
|
103
105
|
}
|
|
104
106
|
end
|
|
105
107
|
end
|
|
@@ -111,7 +113,7 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
111
113
|
facet_search.populate
|
|
112
114
|
|
|
113
115
|
batch.searches.each { |search|
|
|
114
|
-
search.options[setting].
|
|
116
|
+
expect(search.options[setting]).to eq(42)
|
|
115
117
|
}
|
|
116
118
|
end
|
|
117
119
|
|
|
@@ -122,8 +124,8 @@ describe ThinkingSphinx::FacetSearch do
|
|
|
122
124
|
facet_search.populate
|
|
123
125
|
|
|
124
126
|
batch.searches.each do |search|
|
|
125
|
-
search.options[setting].
|
|
126
|
-
search.options[:max_matches].
|
|
127
|
+
expect(search.options[setting]).to eq(10)
|
|
128
|
+
expect(search.options[:max_matches]).to eq(500)
|
|
127
129
|
end
|
|
128
130
|
end
|
|
129
131
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
RSpec.describe ThinkingSphinx::Hooks::GuardPresence do
|
|
6
|
+
let(:subject) do
|
|
7
|
+
ThinkingSphinx::Hooks::GuardPresence.new configuration, stream
|
|
8
|
+
end
|
|
9
|
+
let(:configuration) { double "configuration", :indices_location => "/path" }
|
|
10
|
+
let(:stream) { double "stream", :puts => nil }
|
|
11
|
+
|
|
12
|
+
describe "#call" do
|
|
13
|
+
it "outputs nothing if no guard files exist" do
|
|
14
|
+
allow(Dir).to receive(:[]).with('/path/ts-*.tmp').and_return([])
|
|
15
|
+
|
|
16
|
+
expect(stream).not_to receive(:puts)
|
|
17
|
+
|
|
18
|
+
subject.call
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "outputs a warning if a guard file exists" do
|
|
22
|
+
allow(Dir).to receive(:[]).with('/path/ts-*.tmp').
|
|
23
|
+
and_return(['/path/ts-foo.tmp'])
|
|
24
|
+
|
|
25
|
+
expect(stream).to receive(:puts)
|
|
26
|
+
|
|
27
|
+
subject.call
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ThinkingSphinx; end
|
|
2
4
|
|
|
3
5
|
require 'active_support/core_ext/string/inflections'
|
|
@@ -15,15 +17,31 @@ describe ThinkingSphinx::IndexSet do
|
|
|
15
17
|
stub_const 'ActiveRecord::Base', ar_base
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def class_double(name, *superclasses)
|
|
20
|
+
def class_double(name, methods = {}, *superclasses)
|
|
19
21
|
klass = double 'class', :name => name, :class => Class
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
allow(klass).to receive_messages(
|
|
24
|
+
:ancestors => ([klass] + superclasses + [ar_base]),
|
|
25
|
+
:inheritance_column => :type
|
|
26
|
+
)
|
|
27
|
+
allow(klass).to receive_messages(methods)
|
|
28
|
+
|
|
21
29
|
klass
|
|
22
30
|
end
|
|
23
31
|
|
|
24
32
|
describe '#to_a' do
|
|
33
|
+
let(:article_index) do
|
|
34
|
+
double(:reference => :article, :distributed? => false)
|
|
35
|
+
end
|
|
36
|
+
let(:opinion_article_index) do
|
|
37
|
+
double(:reference => :opinion_article, :distributed? => false)
|
|
38
|
+
end
|
|
39
|
+
let(:page_index) do
|
|
40
|
+
double(:reference => :page, :distributed? => false)
|
|
41
|
+
end
|
|
42
|
+
|
|
25
43
|
it "ensures the indices are loaded" do
|
|
26
|
-
configuration.
|
|
44
|
+
expect(configuration).to receive(:preload_indices)
|
|
27
45
|
|
|
28
46
|
set.to_a
|
|
29
47
|
end
|
|
@@ -37,33 +55,56 @@ describe ThinkingSphinx::IndexSet do
|
|
|
37
55
|
|
|
38
56
|
configuration.indices.replace [article_core, user_core, distributed]
|
|
39
57
|
|
|
40
|
-
set.to_a.
|
|
58
|
+
expect(set.to_a).to eq([article_core, user_core])
|
|
41
59
|
end
|
|
42
60
|
|
|
43
61
|
it "uses indices for the given classes" do
|
|
44
62
|
configuration.indices.replace [
|
|
45
|
-
|
|
46
|
-
double(:reference => :opinion_article, :distributed? => false),
|
|
47
|
-
double(:reference => :page, :distributed? => false)
|
|
63
|
+
article_index, opinion_article_index, page_index
|
|
48
64
|
]
|
|
49
65
|
|
|
50
|
-
options[:classes] = [class_double('Article')]
|
|
66
|
+
options[:classes] = [class_double('Article', :column_names => [])]
|
|
51
67
|
|
|
52
|
-
set.to_a.
|
|
68
|
+
expect(set.to_a).to eq([article_index])
|
|
53
69
|
end
|
|
54
70
|
|
|
55
|
-
it "
|
|
71
|
+
it "uses indices for the given instance's class" do
|
|
56
72
|
configuration.indices.replace [
|
|
57
|
-
|
|
58
|
-
double(:reference => :opinion_article, :distributed? => false),
|
|
59
|
-
double(:reference => :page, :distributed? => false)
|
|
73
|
+
article_index, opinion_article_index, page_index
|
|
60
74
|
]
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
instance_class = class_double('Article', :column_names => [])
|
|
77
|
+
|
|
78
|
+
options[:instances] = [double(:instance, :class => instance_class)]
|
|
79
|
+
|
|
80
|
+
expect(set.to_a).to eq([article_index])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "requests indices for any STI superclasses" do
|
|
84
|
+
configuration.indices.replace [
|
|
85
|
+
article_index, opinion_article_index, page_index
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
article = class_double('Article', :column_names => [:type])
|
|
89
|
+
opinion = class_double('OpinionArticle', {:column_names => [:type]},
|
|
90
|
+
article)
|
|
91
|
+
|
|
92
|
+
options[:classes] = [opinion]
|
|
93
|
+
|
|
94
|
+
expect(set.to_a).to eq([article_index, opinion_article_index])
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "does not use MTI superclasses" do
|
|
98
|
+
configuration.indices.replace [
|
|
99
|
+
article_index, opinion_article_index, page_index
|
|
64
100
|
]
|
|
65
101
|
|
|
66
|
-
|
|
102
|
+
article = class_double('Article', :column_names => [])
|
|
103
|
+
opinion = class_double('OpinionArticle', {:column_names => []}, article)
|
|
104
|
+
|
|
105
|
+
options[:classes] = [opinion]
|
|
106
|
+
|
|
107
|
+
expect(set.to_a).to eq([opinion_article_index])
|
|
67
108
|
end
|
|
68
109
|
|
|
69
110
|
it "uses named indices if names are provided" do
|
|
@@ -73,7 +114,7 @@ describe ThinkingSphinx::IndexSet do
|
|
|
73
114
|
|
|
74
115
|
options[:indices] = ['article_core']
|
|
75
116
|
|
|
76
|
-
set.to_a.
|
|
117
|
+
expect(set.to_a).to eq([article_core])
|
|
77
118
|
end
|
|
78
119
|
|
|
79
120
|
it "selects from the full index set those with matching references" do
|
|
@@ -85,7 +126,7 @@ describe ThinkingSphinx::IndexSet do
|
|
|
85
126
|
|
|
86
127
|
options[:references] = [:book, :article]
|
|
87
128
|
|
|
88
|
-
set.to_a.length.
|
|
129
|
+
expect(set.to_a.length).to eq(2)
|
|
89
130
|
end
|
|
90
131
|
end
|
|
91
132
|
end
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe ThinkingSphinx::Index do
|
|
4
6
|
let(:configuration) { Struct.new(:indices, :settings).new([], {}) }
|
|
5
7
|
|
|
6
8
|
before :each do
|
|
7
|
-
ThinkingSphinx::Configuration.
|
|
9
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => configuration
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
describe '.define' do
|
|
@@ -12,29 +14,29 @@ describe ThinkingSphinx::Index do
|
|
|
12
14
|
|
|
13
15
|
context 'with ActiveRecord' do
|
|
14
16
|
before :each do
|
|
15
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
17
|
+
allow(ThinkingSphinx::ActiveRecord::Index).to receive_messages :new => index
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
it "creates an ActiveRecord index" do
|
|
19
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
20
|
-
with(:user, :with => :active_record).and_return index
|
|
21
|
+
expect(ThinkingSphinx::ActiveRecord::Index).to receive(:new).
|
|
22
|
+
with(:user, { :with => :active_record }).and_return index
|
|
21
23
|
|
|
22
24
|
ThinkingSphinx::Index.define(:user, :with => :active_record)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
it "returns the ActiveRecord index" do
|
|
26
|
-
ThinkingSphinx::Index.define(:user, :with => :active_record).
|
|
27
|
-
|
|
28
|
+
expect(ThinkingSphinx::Index.define(:user, :with => :active_record)).
|
|
29
|
+
to eq([index])
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
it "adds the index to the collection of indices" do
|
|
31
33
|
ThinkingSphinx::Index.define(:user, :with => :active_record)
|
|
32
34
|
|
|
33
|
-
configuration.indices.
|
|
35
|
+
expect(configuration.indices).to include(index)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
it "sets the block in the index" do
|
|
37
|
-
index.
|
|
39
|
+
expect(index).to receive(:definition_block=).with instance_of(Proc)
|
|
38
40
|
|
|
39
41
|
ThinkingSphinx::Index.define(:user, :with => :active_record) do
|
|
40
42
|
indexes name
|
|
@@ -46,19 +48,19 @@ describe ThinkingSphinx::Index do
|
|
|
46
48
|
let(:processor) { double('delta processor') }
|
|
47
49
|
|
|
48
50
|
before :each do
|
|
49
|
-
ThinkingSphinx::Deltas.
|
|
50
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
51
|
+
allow(ThinkingSphinx::Deltas).to receive_messages :processor_for => processor
|
|
52
|
+
allow(ThinkingSphinx::ActiveRecord::Index).to receive(:new).
|
|
51
53
|
and_return(index, delta_index)
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
it "creates two indices with delta settings" do
|
|
55
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
56
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
57
|
+
allow(ThinkingSphinx::ActiveRecord::Index).to receive(:new).and_call_original
|
|
58
|
+
expect(ThinkingSphinx::ActiveRecord::Index).to receive(:new).
|
|
57
59
|
with(:user,
|
|
58
60
|
hash_including(:delta? => false, :delta_processor => processor)
|
|
59
61
|
).once.
|
|
60
62
|
and_return index
|
|
61
|
-
ThinkingSphinx::ActiveRecord::Index.
|
|
63
|
+
expect(ThinkingSphinx::ActiveRecord::Index).to receive(:new).
|
|
62
64
|
with(:user,
|
|
63
65
|
hash_including(:delta? => true, :delta_processor => processor)
|
|
64
66
|
).once.
|
|
@@ -74,13 +76,13 @@ describe ThinkingSphinx::Index do
|
|
|
74
76
|
:with => :active_record,
|
|
75
77
|
:delta => true
|
|
76
78
|
|
|
77
|
-
configuration.indices.
|
|
78
|
-
configuration.indices.
|
|
79
|
+
expect(configuration.indices).to include(index)
|
|
80
|
+
expect(configuration.indices).to include(delta_index)
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
it "sets the block in the index" do
|
|
82
|
-
index.
|
|
83
|
-
delta_index.
|
|
84
|
+
expect(index).to receive(:definition_block=).with instance_of(Proc)
|
|
85
|
+
expect(delta_index).to receive(:definition_block=).with instance_of(Proc)
|
|
84
86
|
|
|
85
87
|
ThinkingSphinx::Index.define(:user,
|
|
86
88
|
:with => :active_record,
|
|
@@ -93,29 +95,29 @@ describe ThinkingSphinx::Index do
|
|
|
93
95
|
|
|
94
96
|
context 'with Real-Time' do
|
|
95
97
|
before :each do
|
|
96
|
-
ThinkingSphinx::RealTime::Index.
|
|
98
|
+
allow(ThinkingSphinx::RealTime::Index).to receive_messages :new => index
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
it "creates a real-time index" do
|
|
100
|
-
ThinkingSphinx::RealTime::Index.
|
|
101
|
-
with(:user, :with => :real_time).and_return index
|
|
102
|
+
expect(ThinkingSphinx::RealTime::Index).to receive(:new).
|
|
103
|
+
with(:user, { :with => :real_time }).and_return index
|
|
102
104
|
|
|
103
105
|
ThinkingSphinx::Index.define(:user, :with => :real_time)
|
|
104
106
|
end
|
|
105
107
|
|
|
106
108
|
it "returns the ActiveRecord index" do
|
|
107
|
-
ThinkingSphinx::Index.define(:user, :with => :real_time).
|
|
108
|
-
|
|
109
|
+
expect(ThinkingSphinx::Index.define(:user, :with => :real_time)).
|
|
110
|
+
to eq([index])
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
it "adds the index to the collection of indices" do
|
|
112
114
|
ThinkingSphinx::Index.define(:user, :with => :real_time)
|
|
113
115
|
|
|
114
|
-
configuration.indices.
|
|
116
|
+
expect(configuration.indices).to include(index)
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
it "sets the block in the index" do
|
|
118
|
-
index.
|
|
120
|
+
expect(index).to receive(:definition_block=).with instance_of(Proc)
|
|
119
121
|
|
|
120
122
|
ThinkingSphinx::Index.define(:user, :with => :real_time) do
|
|
121
123
|
indexes name
|
|
@@ -126,13 +128,13 @@ describe ThinkingSphinx::Index do
|
|
|
126
128
|
|
|
127
129
|
describe '#initialize' do
|
|
128
130
|
it "is fine with no defaults from settings" do
|
|
129
|
-
ThinkingSphinx::Index.new(:user, {}).options.
|
|
131
|
+
expect(ThinkingSphinx::Index.new(:user, {}).options).to eq({})
|
|
130
132
|
end
|
|
131
133
|
|
|
132
134
|
it "respects defaults from settings" do
|
|
133
135
|
configuration.settings['index_options'] = {'delta' => true}
|
|
134
136
|
|
|
135
|
-
ThinkingSphinx::Index.new(:user, {}).options.
|
|
137
|
+
expect(ThinkingSphinx::Index.new(:user, {}).options).to eq({:delta => true})
|
|
136
138
|
end
|
|
137
139
|
end
|
|
138
140
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe ThinkingSphinx::Interfaces::Daemon do
|
|
6
|
+
let(:configuration) { double 'configuration' }
|
|
7
|
+
let(:stream) { double 'stream', :puts => true }
|
|
8
|
+
let(:commander) { double :call => nil }
|
|
9
|
+
let(:interface) {
|
|
10
|
+
ThinkingSphinx::Interfaces::Daemon.new(configuration, {}, stream)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
before :each do
|
|
14
|
+
stub_const 'ThinkingSphinx::Commander', commander
|
|
15
|
+
|
|
16
|
+
allow(commander).to receive(:call).
|
|
17
|
+
with(:running, configuration, {}, stream).and_return(false)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#start' do
|
|
21
|
+
it "starts the daemon" do
|
|
22
|
+
expect(commander).to receive(:call).with(
|
|
23
|
+
:start_detached, configuration, {}, stream
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
interface.start
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "raises an error if the daemon is already running" do
|
|
30
|
+
allow(commander).to receive(:call).
|
|
31
|
+
with(:running, configuration, {}, stream).and_return(true)
|
|
32
|
+
|
|
33
|
+
expect {
|
|
34
|
+
interface.start
|
|
35
|
+
}.to raise_error(ThinkingSphinx::SphinxAlreadyRunning)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#status' do
|
|
40
|
+
it "reports when the daemon is running" do
|
|
41
|
+
allow(commander).to receive(:call).
|
|
42
|
+
with(:running, configuration, {}, stream).and_return(true)
|
|
43
|
+
|
|
44
|
+
expect(stream).to receive(:puts).
|
|
45
|
+
with('The Sphinx daemon searchd is currently running.')
|
|
46
|
+
|
|
47
|
+
interface.status
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "reports when the daemon is not running" do
|
|
51
|
+
allow(commander).to receive(:call).
|
|
52
|
+
with(:running, configuration, {}, stream).and_return(false)
|
|
53
|
+
|
|
54
|
+
expect(stream).to receive(:puts).
|
|
55
|
+
with('The Sphinx daemon searchd is not currently running.')
|
|
56
|
+
|
|
57
|
+
interface.status
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe ThinkingSphinx::Interfaces::SQL do
|
|
6
|
+
let(:interface) { ThinkingSphinx::Interfaces::RealTime.new(
|
|
7
|
+
configuration, {}, stream
|
|
8
|
+
) }
|
|
9
|
+
let(:configuration) { double 'configuration', :controller => controller,
|
|
10
|
+
:render => true, :indices_location => '/path/to/indices',
|
|
11
|
+
:preload_indices => true }
|
|
12
|
+
let(:controller) { double 'controller', :running? => true }
|
|
13
|
+
let(:commander) { double :call => true }
|
|
14
|
+
let(:stream) { double :puts => nil }
|
|
15
|
+
|
|
16
|
+
before :each do
|
|
17
|
+
stub_const "ThinkingSphinx::Commander", commander
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#clear' do
|
|
21
|
+
let(:plain_index) { double(:type => 'plain') }
|
|
22
|
+
let(:users_index) { double(:name => 'users', :type => 'rt', :render => true,
|
|
23
|
+
:path => '/path/to/my/index/users') }
|
|
24
|
+
let(:parts_index) { double(:name => 'parts', :type => 'rt', :render => true,
|
|
25
|
+
:path => '/path/to/my/index/parts') }
|
|
26
|
+
|
|
27
|
+
before :each do
|
|
28
|
+
allow(configuration).to receive_messages(
|
|
29
|
+
:indices => [plain_index, users_index, parts_index]
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'prepares the indices' do
|
|
34
|
+
expect(commander).to receive(:call).with(
|
|
35
|
+
:prepare, configuration, {}, stream
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
interface.clear
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'invokes the clear command' do
|
|
42
|
+
expect(commander).to receive(:call).with(
|
|
43
|
+
:clear_real_time,
|
|
44
|
+
configuration,
|
|
45
|
+
{:indices => [users_index, parts_index]},
|
|
46
|
+
stream
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
interface.clear
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with options[:index_names]" do
|
|
53
|
+
let(:interface) { ThinkingSphinx::Interfaces::RealTime.new(
|
|
54
|
+
configuration, {:index_names => ['users']}, stream
|
|
55
|
+
) }
|
|
56
|
+
|
|
57
|
+
it "removes each file for real-time indices that match :index_filter" do
|
|
58
|
+
expect(commander).to receive(:call).with(
|
|
59
|
+
:clear_real_time,
|
|
60
|
+
configuration,
|
|
61
|
+
{:index_names => ['users'], :indices => [users_index]},
|
|
62
|
+
stream
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
interface.clear
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#index' do
|
|
71
|
+
let(:plain_index) { double(:type => 'plain') }
|
|
72
|
+
let(:users_index) { double(name: 'users', :type => 'rt') }
|
|
73
|
+
let(:parts_index) { double(name: 'parts', :type => 'rt') }
|
|
74
|
+
|
|
75
|
+
before :each do
|
|
76
|
+
allow(configuration).to receive_messages(
|
|
77
|
+
:indices => [plain_index, users_index, parts_index]
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'invokes the index command with real-time indices' do
|
|
82
|
+
expect(commander).to receive(:call).with(
|
|
83
|
+
:index_real_time,
|
|
84
|
+
configuration,
|
|
85
|
+
{:indices => [users_index, parts_index]},
|
|
86
|
+
stream
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
interface.index
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context "with options[:index_names]" do
|
|
93
|
+
let(:interface) { ThinkingSphinx::Interfaces::RealTime.new(
|
|
94
|
+
configuration, {:index_names => ['users']}, stream
|
|
95
|
+
) }
|
|
96
|
+
|
|
97
|
+
it 'invokes the index command for matching indices' do
|
|
98
|
+
expect(commander).to receive(:call).with(
|
|
99
|
+
:index_real_time,
|
|
100
|
+
configuration,
|
|
101
|
+
{:index_names => ['users'], :indices => [users_index]},
|
|
102
|
+
stream
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
interface.index
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|