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,77 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Grouping search results by attributes', :live => true do
|
|
4
6
|
it "groups by the provided attribute" do
|
|
5
|
-
snuff = Book.create! :title => 'Snuff', :
|
|
6
|
-
earth = Book.create! :title => 'The Long Earth', :
|
|
7
|
-
dodger = Book.create! :title => 'Dodger', :
|
|
7
|
+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
|
|
8
|
+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
|
|
9
|
+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
|
|
8
10
|
|
|
9
11
|
index
|
|
10
12
|
|
|
11
|
-
Book.search(:group_by => :
|
|
13
|
+
expect(Book.search(:group_by => :publishing_year).to_a).to eq([snuff, earth])
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "allows sorting within the group" do
|
|
15
|
-
snuff = Book.create! :title => 'Snuff', :
|
|
16
|
-
earth = Book.create! :title => 'The Long Earth', :
|
|
17
|
-
dodger = Book.create! :title => 'Dodger', :
|
|
17
|
+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
|
|
18
|
+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
|
|
19
|
+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
|
|
18
20
|
|
|
19
21
|
index
|
|
20
22
|
|
|
21
|
-
Book.search(:group_by => :
|
|
22
|
-
|
|
23
|
+
expect(Book.search(:group_by => :publishing_year, :order_group_by => 'title ASC').to_a).
|
|
24
|
+
to eq([snuff, dodger])
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
it "allows enumerating by count" do
|
|
26
|
-
snuff = Book.create! :title => 'Snuff', :
|
|
27
|
-
earth = Book.create! :title => 'The Long Earth', :
|
|
28
|
-
dodger = Book.create! :title => 'Dodger', :
|
|
28
|
+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
|
|
29
|
+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
|
|
30
|
+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
|
|
29
31
|
|
|
30
32
|
index
|
|
31
33
|
|
|
32
34
|
expectations = [[snuff, 1], [earth, 2]]
|
|
33
35
|
|
|
34
|
-
Book.search(:group_by => :
|
|
36
|
+
Book.search(:group_by => :publishing_year).each_with_count do |book, count|
|
|
35
37
|
expectation = expectations.shift
|
|
36
38
|
|
|
37
|
-
book.
|
|
38
|
-
count.
|
|
39
|
+
expect(book).to eq(expectation.first)
|
|
40
|
+
expect(count).to eq(expectation.last)
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
it "allows enumerating by group" do
|
|
43
|
-
snuff = Book.create! :title => 'Snuff', :
|
|
44
|
-
earth = Book.create! :title => 'The Long Earth', :
|
|
45
|
-
dodger = Book.create! :title => 'Dodger', :
|
|
45
|
+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
|
|
46
|
+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
|
|
47
|
+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
|
|
46
48
|
|
|
47
49
|
index
|
|
48
50
|
|
|
49
51
|
expectations = [[snuff, 2011], [earth, 2012]]
|
|
50
52
|
|
|
51
|
-
Book.search(:group_by => :
|
|
53
|
+
Book.search(:group_by => :publishing_year).each_with_group do |book, group|
|
|
52
54
|
expectation = expectations.shift
|
|
53
55
|
|
|
54
|
-
book.
|
|
55
|
-
group.
|
|
56
|
+
expect(book).to eq(expectation.first)
|
|
57
|
+
expect(group).to eq(expectation.last)
|
|
56
58
|
end
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
it "allows enumerating by group and count" do
|
|
60
|
-
snuff = Book.create! :title => 'Snuff', :
|
|
61
|
-
earth = Book.create! :title => 'The Long Earth', :
|
|
62
|
-
dodger = Book.create! :title => 'Dodger', :
|
|
62
|
+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
|
|
63
|
+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
|
|
64
|
+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
|
|
63
65
|
|
|
64
66
|
index
|
|
65
67
|
|
|
66
68
|
expectations = [[snuff, 2011, 1], [earth, 2012, 2]]
|
|
67
|
-
search = Book.search(:group_by => :
|
|
69
|
+
search = Book.search(:group_by => :publishing_year)
|
|
68
70
|
|
|
69
71
|
search.each_with_group_and_count do |book, group, count|
|
|
70
72
|
expectation = expectations.shift
|
|
71
73
|
|
|
72
|
-
book.
|
|
73
|
-
group.
|
|
74
|
-
count.
|
|
74
|
+
expect(book).to eq(expectation[0])
|
|
75
|
+
expect(group).to eq(expectation[1])
|
|
76
|
+
expect(count).to eq(expectation[2])
|
|
75
77
|
end
|
|
76
78
|
end
|
|
77
79
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Index options' do
|
|
@@ -14,11 +16,11 @@ describe 'Index options' do
|
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
it "keeps #{type}_fields blank" do
|
|
17
|
-
index.send("#{type}_fields").
|
|
19
|
+
expect(index.send("#{type}_fields")).to be_nil
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
it "sets min_#{type}_len" do
|
|
21
|
-
index.send("min_#{type}_len").
|
|
23
|
+
expect(index.send("min_#{type}_len")).to eq(3)
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -33,11 +35,11 @@ describe 'Index options' do
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
it "#{type}_fields should contain the field" do
|
|
36
|
-
index.send("#{type}_fields").
|
|
38
|
+
expect(index.send("#{type}_fields")).to eq('title')
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
it "sets min_#{type}_len" do
|
|
40
|
-
index.send("min_#{type}_len").
|
|
42
|
+
expect(index.send("min_#{type}_len")).to eq(3)
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
end
|
|
@@ -57,12 +59,12 @@ describe 'Index options' do
|
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
it "stores each source definition" do
|
|
60
|
-
index.sources.length.
|
|
62
|
+
expect(index.sources.length).to eq(2)
|
|
61
63
|
end
|
|
62
64
|
|
|
63
65
|
it "treats each source as separate" do
|
|
64
|
-
index.sources.first.fields.length.
|
|
65
|
-
index.sources.last.fields.length.
|
|
66
|
+
expect(index.sources.first.fields.length).to eq(2)
|
|
67
|
+
expect(index.sources.last.fields.length).to eq(3)
|
|
66
68
|
end
|
|
67
69
|
end
|
|
68
70
|
|
|
@@ -77,11 +79,11 @@ describe 'Index options' do
|
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
it "declares wordcount fields" do
|
|
80
|
-
index.sources.first.sql_field_str2wordcount.
|
|
82
|
+
expect(index.sources.first.sql_field_str2wordcount).to eq(['title'])
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
it "declares wordcount attributes" do
|
|
84
|
-
index.sources.first.sql_attr_str2wordcount.
|
|
86
|
+
expect(index.sources.first.sql_attr_str2wordcount).to eq(['content'])
|
|
85
87
|
end
|
|
86
88
|
end
|
|
87
89
|
|
|
@@ -98,15 +100,15 @@ describe 'Index options' do
|
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
it "allows for core source settings" do
|
|
101
|
-
index.sources.first.sql_range_step.
|
|
103
|
+
expect(index.sources.first.sql_range_step).to eq(5)
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
it "allows for source options" do
|
|
105
|
-
index.sources.first.disable_range
|
|
107
|
+
expect(index.sources.first.disable_range?).to be_truthy
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
it "respects sql_query_pre values" do
|
|
109
|
-
index.sources.first.sql_query_pre.
|
|
111
|
+
expect(index.sources.first.sql_query_pre).to include("DO STUFF")
|
|
110
112
|
end
|
|
111
113
|
end
|
|
112
114
|
|
|
@@ -130,23 +132,23 @@ describe 'Index options' do
|
|
|
130
132
|
end
|
|
131
133
|
|
|
132
134
|
it "prioritises index-level options over YAML options" do
|
|
133
|
-
index.min_infix_len.
|
|
135
|
+
expect(index.min_infix_len).to eq(1)
|
|
134
136
|
end
|
|
135
137
|
|
|
136
138
|
it "prioritises index-level source options" do
|
|
137
|
-
index.sources.first.sql_range_step.
|
|
139
|
+
expect(index.sources.first.sql_range_step).to eq(20)
|
|
138
140
|
end
|
|
139
141
|
|
|
140
142
|
it "keeps index-level options prioritised when rendered again" do
|
|
141
143
|
index.render
|
|
142
144
|
|
|
143
|
-
index.min_infix_len.
|
|
145
|
+
expect(index.min_infix_len).to eq(1)
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
it "keeps index-level options prioritised when rendered again" do
|
|
147
149
|
index.render
|
|
148
150
|
|
|
149
|
-
index.sources.first.sql_range_step.
|
|
151
|
+
expect(index.sources.first.sql_range_step).to eq(20)
|
|
150
152
|
end
|
|
151
153
|
end
|
|
152
154
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Indexing', :live => true do
|
|
@@ -8,7 +10,7 @@ describe 'Indexing', :live => true do
|
|
|
8
10
|
|
|
9
11
|
article = Article.create! :title => 'Pancakes'
|
|
10
12
|
index 'article_core'
|
|
11
|
-
Article.search.
|
|
13
|
+
expect(Article.search).to be_empty
|
|
12
14
|
|
|
13
15
|
FileUtils.rm path
|
|
14
16
|
end
|
|
@@ -20,7 +22,7 @@ describe 'Indexing', :live => true do
|
|
|
20
22
|
|
|
21
23
|
article = Article.create! :title => 'Pancakes'
|
|
22
24
|
index 'article_core'
|
|
23
|
-
Article.search.
|
|
25
|
+
expect(Article.search).not_to be_empty
|
|
24
26
|
|
|
25
27
|
FileUtils.rm path
|
|
26
28
|
end
|
|
@@ -31,6 +33,6 @@ describe 'Indexing', :live => true do
|
|
|
31
33
|
index 'article_core'
|
|
32
34
|
|
|
33
35
|
file = Rails.root.join('db/sphinx/test/ts-article_core.tmp')
|
|
34
|
-
File.exist?(file).
|
|
36
|
+
expect(File.exist?(file)).to be_falsey
|
|
35
37
|
end
|
|
36
38
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "acceptance/spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Merging deltas", :live => true do
|
|
6
|
+
it "merges in new records" do
|
|
7
|
+
guards = Book.create(
|
|
8
|
+
:title => "Guards! Guards!", :author => "Terry Pratchett"
|
|
9
|
+
)
|
|
10
|
+
sleep 0.25
|
|
11
|
+
|
|
12
|
+
expect(
|
|
13
|
+
Book.search("Terry Pratchett", :indices => ["book_delta"]).to_a
|
|
14
|
+
).to eq([guards])
|
|
15
|
+
expect(
|
|
16
|
+
Book.search("Terry Pratchett", :indices => ["book_core"]).to_a
|
|
17
|
+
).to be_empty
|
|
18
|
+
|
|
19
|
+
merge
|
|
20
|
+
guards.reload
|
|
21
|
+
|
|
22
|
+
expect(
|
|
23
|
+
Book.search("Terry Pratchett", :indices => ["book_core"]).to_a
|
|
24
|
+
).to eq([guards])
|
|
25
|
+
expect(guards.delta).to eq(false)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "merges in changed records" do
|
|
29
|
+
race = Book.create(
|
|
30
|
+
:title => "The Hate Space", :author => "Maxine Beneba Clarke"
|
|
31
|
+
)
|
|
32
|
+
index
|
|
33
|
+
expect(
|
|
34
|
+
Book.search("Space", :indices => ["book_core"]).to_a
|
|
35
|
+
).to eq([race])
|
|
36
|
+
|
|
37
|
+
race.reload.update :title => "The Hate Race"
|
|
38
|
+
sleep 0.25
|
|
39
|
+
expect(
|
|
40
|
+
Book.search("Race", :indices => ["book_delta"]).to_a
|
|
41
|
+
).to eq([race])
|
|
42
|
+
expect(
|
|
43
|
+
Book.search("Race", :indices => ["book_core"]).to_a
|
|
44
|
+
).to be_empty
|
|
45
|
+
|
|
46
|
+
merge
|
|
47
|
+
race.reload
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
Book.search("Race", :indices => ["book_core"]).to_a
|
|
51
|
+
).to eq([race])
|
|
52
|
+
expect(
|
|
53
|
+
Book.search("Race", :indices => ["book_delta"]).to_a
|
|
54
|
+
).to eq([race])
|
|
55
|
+
expect(
|
|
56
|
+
Book.search("Space", :indices => ["book_core"]).to_a
|
|
57
|
+
).to be_empty
|
|
58
|
+
expect(race.delta).to eq(false)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "maintains existing records" do
|
|
62
|
+
race = Book.create(
|
|
63
|
+
:title => "The Hate Race", :author => "Maxine Beneba Clarke"
|
|
64
|
+
)
|
|
65
|
+
index
|
|
66
|
+
|
|
67
|
+
soil = Book.create(
|
|
68
|
+
:title => "Foreign Soil", :author => "Maxine Beneba Clarke"
|
|
69
|
+
)
|
|
70
|
+
sleep 0.25
|
|
71
|
+
expect(
|
|
72
|
+
Book.search("Soil", :indices => ["book_delta"]).to_a
|
|
73
|
+
).to eq([soil])
|
|
74
|
+
expect(
|
|
75
|
+
Book.search("Soil", :indices => ["book_core"]).to_a
|
|
76
|
+
).to be_empty
|
|
77
|
+
expect(
|
|
78
|
+
Book.search("Race", :indices => ["book_core"]).to_a
|
|
79
|
+
).to eq([race])
|
|
80
|
+
|
|
81
|
+
merge
|
|
82
|
+
|
|
83
|
+
expect(
|
|
84
|
+
Book.search("Soil", :indices => ["book_core"]).to_a
|
|
85
|
+
).to eq([soil])
|
|
86
|
+
expect(
|
|
87
|
+
Book.search("Race", :indices => ["book_core"]).to_a
|
|
88
|
+
).to eq([race])
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -1,24 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Paginating search results', :live => true do
|
|
4
6
|
it "tracks how many results there are in total" do
|
|
7
|
+
expect(Article.search.total_entries).to be_zero
|
|
8
|
+
|
|
5
9
|
21.times { |number| Article.create :title => "Article #{number}" }
|
|
6
10
|
index
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
if ENV["SPHINX_ENGINE"] == "manticore" && ENV["SPHINX_VERSION"].to_f >= 4.0
|
|
13
|
+
# I suspect this is a bug in Manticore?
|
|
14
|
+
expect(Article.search.total_entries).to eq(22)
|
|
15
|
+
else
|
|
16
|
+
expect(Article.search.total_entries).to eq(21)
|
|
17
|
+
end
|
|
9
18
|
end
|
|
10
19
|
|
|
11
20
|
it "paginates the result set by default" do
|
|
21
|
+
expect(Article.search.total_entries).to be_zero
|
|
22
|
+
|
|
12
23
|
21.times { |number| Article.create :title => "Article #{number}" }
|
|
13
24
|
index
|
|
14
25
|
|
|
15
|
-
Article.search.length.
|
|
26
|
+
expect(Article.search.length).to eq(20)
|
|
16
27
|
end
|
|
17
28
|
|
|
18
29
|
it "tracks the number of pages" do
|
|
30
|
+
expect(Article.search.total_entries).to be_zero
|
|
31
|
+
|
|
19
32
|
21.times { |number| Article.create :title => "Article #{number}" }
|
|
20
33
|
index
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
if ENV["SPHINX_ENGINE"] == "manticore" && ENV["SPHINX_VERSION"].to_f >= 4.0
|
|
36
|
+
# I suspect this is a bug in Manticore?
|
|
37
|
+
expect(Article.search.total_pages).to eq(1)
|
|
38
|
+
else
|
|
39
|
+
expect(Article.search.total_pages).to eq(2)
|
|
40
|
+
end
|
|
23
41
|
end
|
|
24
42
|
end
|
|
@@ -1,17 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Updates to records in real-time indices', :live => true do
|
|
4
6
|
it "handles fields with unicode nulls" do
|
|
5
7
|
product = Product.create! :name => "Widget \u0000"
|
|
6
8
|
|
|
7
|
-
Product.search.first.
|
|
8
|
-
end
|
|
9
|
+
expect(Product.search.first).to eq(product)
|
|
10
|
+
end unless ENV['DATABASE'] == 'postgresql'
|
|
9
11
|
|
|
10
12
|
it "handles attributes for sortable fields accordingly" do
|
|
11
13
|
product = Product.create! :name => 'Red Fish'
|
|
12
|
-
product.
|
|
14
|
+
product.update :name => 'Blue Fish'
|
|
15
|
+
|
|
16
|
+
expect(Product.search('blue fish', :indices => ['product_core']).to_a).
|
|
17
|
+
to eq([product])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "handles inserts and updates for namespaced models" do
|
|
21
|
+
person = Admin::Person.create :name => 'Death'
|
|
22
|
+
|
|
23
|
+
expect(Admin::Person.search('Death').to_a).to eq([person])
|
|
24
|
+
|
|
25
|
+
person.update :name => 'Mort'
|
|
26
|
+
|
|
27
|
+
expect(Admin::Person.search('Death').to_a).to be_empty
|
|
28
|
+
expect(Admin::Person.search('Mort').to_a).to eq([person])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "can use direct interface for upserting records" do
|
|
32
|
+
Admin::Person.connection.execute <<~SQL
|
|
33
|
+
INSERT INTO admin_people (name, created_at, updated_at)
|
|
34
|
+
VALUES ('Pat', now(), now());
|
|
35
|
+
SQL
|
|
36
|
+
|
|
37
|
+
expect(Admin::Person.search('Pat').to_a).to be_empty
|
|
38
|
+
|
|
39
|
+
instance = Admin::Person.find_by(:name => 'Pat')
|
|
40
|
+
ThinkingSphinx::Processor.new(instance: instance).upsert
|
|
41
|
+
|
|
42
|
+
expect(Admin::Person.search('Pat').to_a).to eq([instance])
|
|
43
|
+
|
|
44
|
+
Admin::Person.connection.execute <<~SQL
|
|
45
|
+
UPDATE admin_people SET name = 'Patrick' WHERE name = 'Pat';
|
|
46
|
+
SQL
|
|
47
|
+
|
|
48
|
+
expect(Admin::Person.search('Patrick').to_a).to be_empty
|
|
49
|
+
|
|
50
|
+
instance.reload
|
|
51
|
+
ThinkingSphinx::Processor.new(model: Admin::Person, id: instance.id).upsert
|
|
52
|
+
|
|
53
|
+
expect(Admin::Person.search('Patrick').to_a).to eq([instance])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "can use direct interface for processing records outside scope" do
|
|
57
|
+
Article.connection.execute <<~SQL
|
|
58
|
+
INSERT INTO articles (title, published, created_at, updated_at)
|
|
59
|
+
VALUES ('Nice Title', TRUE, now(), now());
|
|
60
|
+
SQL
|
|
61
|
+
|
|
62
|
+
article = Article.last
|
|
63
|
+
|
|
64
|
+
ThinkingSphinx::Processor.new(model: article.class, id: article.id).sync
|
|
65
|
+
|
|
66
|
+
expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to include(article)
|
|
67
|
+
|
|
68
|
+
Article.connection.execute <<~SQL
|
|
69
|
+
UPDATE articles SET published = FALSE WHERE title = 'Nice Title';
|
|
70
|
+
SQL
|
|
71
|
+
ThinkingSphinx::Processor.new(model: article.class, id: article.id).sync
|
|
72
|
+
|
|
73
|
+
expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to be_empty
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "can use direct interface for processing deleted records" do
|
|
77
|
+
Article.connection.execute <<~SQL
|
|
78
|
+
INSERT INTO articles (title, published, created_at, updated_at)
|
|
79
|
+
VALUES ('Nice Title', TRUE, now(), now());
|
|
80
|
+
SQL
|
|
81
|
+
|
|
82
|
+
article = Article.last
|
|
83
|
+
ThinkingSphinx::Processor.new(:instance => article).sync
|
|
84
|
+
|
|
85
|
+
expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to include(article)
|
|
86
|
+
|
|
87
|
+
Article.connection.execute <<~SQL
|
|
88
|
+
DELETE FROM articles where title = 'Nice Title';
|
|
89
|
+
SQL
|
|
90
|
+
|
|
91
|
+
ThinkingSphinx::Processor.new(:instance => article).sync
|
|
92
|
+
|
|
93
|
+
expect(ThinkingSphinx.search('Nice', :indices => ["published_articles_core"])).to be_empty
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "syncs records in real-time index with alternate ids" do
|
|
97
|
+
Album.connection.execute <<~SQL
|
|
98
|
+
INSERT INTO albums (id, name, artist, integer_id)
|
|
99
|
+
VALUES ('#{("a".."z").to_a.sample}', 'Sing to the Moon', 'Laura Mvula', #{rand(10000)});
|
|
100
|
+
SQL
|
|
101
|
+
|
|
102
|
+
album = Album.last
|
|
103
|
+
ThinkingSphinx::Processor.new(:model => Album, id: album.integer_id).sync
|
|
104
|
+
|
|
105
|
+
expect(ThinkingSphinx.search('Laura', :indices => ["album_real_core"])).to include(album)
|
|
106
|
+
|
|
107
|
+
Article.connection.execute <<~SQL
|
|
108
|
+
DELETE FROM albums where id = '#{album.id}';
|
|
109
|
+
SQL
|
|
110
|
+
|
|
111
|
+
ThinkingSphinx::Processor.new(:instance => album).sync
|
|
13
112
|
|
|
14
|
-
|
|
15
|
-
should == [product]
|
|
113
|
+
expect(ThinkingSphinx.search('Laura', :indices => ["album_real_core"])).to be_empty
|
|
16
114
|
end
|
|
17
115
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Hiding deleted records from search results', :live => true do
|
|
@@ -5,32 +7,62 @@ describe 'Hiding deleted records from search results', :live => true do
|
|
|
5
7
|
pancakes = Article.create! :title => 'Pancakes'
|
|
6
8
|
index
|
|
7
9
|
|
|
8
|
-
Article.search('pancakes').
|
|
10
|
+
expect(Article.search('pancakes')).not_to be_empty
|
|
9
11
|
pancakes.destroy
|
|
10
12
|
|
|
11
|
-
Article.search('pancakes').
|
|
13
|
+
expect(Article.search('pancakes')).to be_empty
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "will catch stale records deleted without callbacks being fired" do
|
|
15
17
|
pancakes = Article.create! :title => 'Pancakes'
|
|
16
18
|
index
|
|
17
19
|
|
|
18
|
-
Article.search('pancakes').
|
|
20
|
+
expect(Article.search('pancakes')).not_to be_empty
|
|
19
21
|
Article.connection.execute "DELETE FROM articles WHERE id = #{pancakes.id}"
|
|
20
22
|
|
|
21
|
-
Article.search('pancakes').
|
|
23
|
+
expect(Article.search('pancakes')).to be_empty
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
it "removes records from real-time index results" do
|
|
25
27
|
product = Product.create! :name => 'Shiny'
|
|
26
28
|
|
|
27
|
-
Product.search('Shiny', :indices => ['product_core']).to_a.
|
|
28
|
-
|
|
29
|
+
expect(Product.search('Shiny', :indices => ['product_core']).to_a).
|
|
30
|
+
to eq([product])
|
|
31
|
+
|
|
32
|
+
product.destroy
|
|
33
|
+
|
|
34
|
+
expect(Product.search_for_ids('Shiny', :indices => ['product_core'])).
|
|
35
|
+
to be_empty
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "removes records from real-time index results with alternate ids" do
|
|
39
|
+
album = Album.create! :name => 'Sing to the Moon', :artist => 'Laura Mvula'
|
|
40
|
+
|
|
41
|
+
expect(Album.search('Sing', :indices => ['album_real_core']).to_a).
|
|
42
|
+
to eq([album])
|
|
43
|
+
|
|
44
|
+
album.destroy
|
|
45
|
+
|
|
46
|
+
expect(Album.search_for_ids('Sing', :indices => ['album_real_core'])).
|
|
47
|
+
to be_empty
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "does not remove real-time results when callbacks are disabled" do
|
|
51
|
+
original = ThinkingSphinx::Configuration.instance.
|
|
52
|
+
settings['real_time_callbacks']
|
|
53
|
+
product = Product.create! :name => 'Shiny'
|
|
54
|
+
expect(Product.search('Shiny', :indices => ['product_core']).to_a).
|
|
55
|
+
to eq([product])
|
|
56
|
+
|
|
57
|
+
ThinkingSphinx::Configuration.instance.
|
|
58
|
+
settings['real_time_callbacks'] = false
|
|
29
59
|
|
|
30
60
|
product.destroy
|
|
61
|
+
expect(Product.search_for_ids('Shiny', :indices => ['product_core'])).
|
|
62
|
+
not_to be_empty
|
|
31
63
|
|
|
32
|
-
|
|
33
|
-
|
|
64
|
+
ThinkingSphinx::Configuration.instance.
|
|
65
|
+
settings['real_time_callbacks'] = original
|
|
34
66
|
end
|
|
35
67
|
|
|
36
68
|
it "deletes STI child classes from parent indices" do
|
|
@@ -40,4 +72,28 @@ describe 'Hiding deleted records from search results', :live => true do
|
|
|
40
72
|
|
|
41
73
|
expect(Bird.search_for_ids('duck')).to be_empty
|
|
42
74
|
end
|
|
75
|
+
|
|
76
|
+
it "can use a direct interface for processing records" do
|
|
77
|
+
pancakes = Article.create! :title => 'Pancakes'
|
|
78
|
+
index
|
|
79
|
+
expect(Article.search('pancakes')).not_to be_empty
|
|
80
|
+
|
|
81
|
+
Article.connection.execute "DELETE FROM articles WHERE id = #{pancakes.id}"
|
|
82
|
+
expect(Article.search_for_ids('pancakes')).not_to be_empty
|
|
83
|
+
|
|
84
|
+
ThinkingSphinx::Processor.new(instance: pancakes).delete
|
|
85
|
+
expect(Article.search_for_ids('pancakes')).to be_empty
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "can use a direct interface for processing records without an instance" do
|
|
89
|
+
pancakes = Article.create! :title => 'Pancakes'
|
|
90
|
+
index
|
|
91
|
+
expect(Article.search('pancakes')).not_to be_empty
|
|
92
|
+
|
|
93
|
+
Article.connection.execute "DELETE FROM articles WHERE id = #{pancakes.id}"
|
|
94
|
+
expect(Article.search_for_ids('pancakes')).not_to be_empty
|
|
95
|
+
|
|
96
|
+
ThinkingSphinx::Processor.new(model: Article, id: pancakes.id).delete
|
|
97
|
+
expect(Article.search_for_ids('pancakes')).to be_empty
|
|
98
|
+
end
|
|
43
99
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Get search result counts', :live => true do
|
|
@@ -5,7 +7,7 @@ describe 'Get search result counts', :live => true do
|
|
|
5
7
|
4.times { |i| Article.create :title => "Article #{i}" }
|
|
6
8
|
index
|
|
7
9
|
|
|
8
|
-
Article.search_count.
|
|
10
|
+
expect(Article.search_count).to eq(4)
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
it "returns counts across all models" do
|
|
@@ -13,6 +15,6 @@ describe 'Get search result counts', :live => true do
|
|
|
13
15
|
2.times { |i| Book.create :title => "Book #{i}" }
|
|
14
16
|
index
|
|
15
17
|
|
|
16
|
-
ThinkingSphinx.count.
|
|
18
|
+
expect(ThinkingSphinx.count).to eq(5)
|
|
17
19
|
end
|
|
18
20
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching for just instance Ids', :live => true do
|
|
@@ -6,7 +8,7 @@ describe 'Searching for just instance Ids', :live => true do
|
|
|
6
8
|
waffles = Article.create! :title => 'Waffles'
|
|
7
9
|
index
|
|
8
10
|
|
|
9
|
-
Article.search_for_ids('pancakes').to_a.
|
|
11
|
+
expect(Article.search_for_ids('pancakes').to_a).to eq([pancakes.id])
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it "works across the global context" do
|
|
@@ -14,6 +16,6 @@ describe 'Searching for just instance Ids', :live => true do
|
|
|
14
16
|
book = Book.create! :title => 'American Gods'
|
|
15
17
|
index
|
|
16
18
|
|
|
17
|
-
ThinkingSphinx.search_for_ids.to_a.
|
|
19
|
+
expect(ThinkingSphinx.search_for_ids.to_a).to match_array([article.id, book.id])
|
|
18
20
|
end
|
|
19
21
|
end
|