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 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching across models', :live => true do
|
|
@@ -5,7 +7,7 @@ describe 'Searching across models', :live => true do
|
|
|
5
7
|
article = Article.create! :title => 'Pancakes'
|
|
6
8
|
index
|
|
7
9
|
|
|
8
|
-
ThinkingSphinx.search.first.
|
|
10
|
+
expect(ThinkingSphinx.search.first).to eq(article)
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
it "returns results matching the given query" do
|
|
@@ -14,8 +16,8 @@ describe 'Searching across models', :live => true do
|
|
|
14
16
|
index
|
|
15
17
|
|
|
16
18
|
articles = ThinkingSphinx.search 'pancakes'
|
|
17
|
-
articles.
|
|
18
|
-
articles.
|
|
19
|
+
expect(articles).to include(pancakes)
|
|
20
|
+
expect(articles).not_to include(waffles)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it "handles results from different models" do
|
|
@@ -23,7 +25,7 @@ describe 'Searching across models', :live => true do
|
|
|
23
25
|
book = Book.create! :title => 'American Gods'
|
|
24
26
|
index
|
|
25
27
|
|
|
26
|
-
ThinkingSphinx.search.to_a.
|
|
28
|
+
expect(ThinkingSphinx.search.to_a).to match_array([article, book])
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
it "filters by multiple classes" do
|
|
@@ -32,7 +34,14 @@ describe 'Searching across models', :live => true do
|
|
|
32
34
|
user = User.create! :name => 'Pat'
|
|
33
35
|
index
|
|
34
36
|
|
|
35
|
-
ThinkingSphinx.search(:classes => [User, Article]).to_a.
|
|
36
|
-
|
|
37
|
+
expect(ThinkingSphinx.search(:classes => [User, Article]).to_a).
|
|
38
|
+
to match_array([article, user])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "has a 'none' default scope" do
|
|
42
|
+
article = Article.create! :title => 'Pancakes'
|
|
43
|
+
index
|
|
44
|
+
|
|
45
|
+
expect(ThinkingSphinx.none).to be_empty
|
|
37
46
|
end
|
|
38
47
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
multi_schema = MultiSchema.new
|
|
@@ -16,23 +18,23 @@ describe 'Searching across PostgreSQL schemas', :live => true do
|
|
|
16
18
|
it 'can distinguish between objects with the same primary key' do
|
|
17
19
|
multi_schema.switch :public
|
|
18
20
|
jekyll = Product.create name: 'Doctor Jekyll'
|
|
19
|
-
Product.search('Jekyll', :retry_stale => false).to_a.
|
|
20
|
-
Product.search(:retry_stale => false).to_a.
|
|
21
|
+
expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([jekyll])
|
|
22
|
+
expect(Product.search(:retry_stale => false).to_a).to eq([jekyll])
|
|
21
23
|
|
|
22
24
|
multi_schema.switch :thinking_sphinx
|
|
23
25
|
hyde = Product.create name: 'Mister Hyde'
|
|
24
|
-
Product.search('Jekyll', :retry_stale => false).to_a.
|
|
25
|
-
Product.search('Hyde', :retry_stale => false).to_a.
|
|
26
|
-
Product.search(:retry_stale => false).to_a.
|
|
26
|
+
expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([])
|
|
27
|
+
expect(Product.search('Hyde', :retry_stale => false).to_a).to eq([hyde])
|
|
28
|
+
expect(Product.search(:retry_stale => false).to_a).to eq([hyde])
|
|
27
29
|
|
|
28
30
|
multi_schema.switch :public
|
|
29
|
-
Product.search('Jekyll', :retry_stale => false).to_a.
|
|
30
|
-
Product.search(:retry_stale => false).to_a.
|
|
31
|
-
Product.search('Hyde', :retry_stale => false).to_a.
|
|
31
|
+
expect(Product.search('Jekyll', :retry_stale => false).to_a).to eq([jekyll])
|
|
32
|
+
expect(Product.search(:retry_stale => false).to_a).to eq([jekyll])
|
|
33
|
+
expect(Product.search('Hyde', :retry_stale => false).to_a).to eq([])
|
|
32
34
|
|
|
33
|
-
Product.search(
|
|
35
|
+
expect(Product.search(
|
|
34
36
|
:middleware => ThinkingSphinx::Middlewares::RAW_ONLY,
|
|
35
37
|
:indices => ['product_core', 'product_two_core']
|
|
36
|
-
).to_a.length.
|
|
38
|
+
).to_a.length).to eq(2)
|
|
37
39
|
end
|
|
38
40
|
end if multi_schema.active?
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching on fields', :live => true do
|
|
@@ -8,8 +10,8 @@ describe 'Searching on fields', :live => true do
|
|
|
8
10
|
index
|
|
9
11
|
|
|
10
12
|
articles = Article.search :conditions => {:title => 'pancakes'}
|
|
11
|
-
articles.
|
|
12
|
-
articles.
|
|
13
|
+
expect(articles).to include(pancakes)
|
|
14
|
+
expect(articles).not_to include(waffles)
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
it "limits results for a field from an association" do
|
|
@@ -17,7 +19,7 @@ describe 'Searching on fields', :live => true do
|
|
|
17
19
|
pancakes = Article.create! :title => 'Pancakes', :user => user
|
|
18
20
|
index
|
|
19
21
|
|
|
20
|
-
Article.search(:conditions => {:user => 'pat'}).first.
|
|
22
|
+
expect(Article.search(:conditions => {:user => 'pat'}).first).to eq(pancakes)
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
it "returns results with matches from grouped fields" do
|
|
@@ -26,23 +28,23 @@ describe 'Searching on fields', :live => true do
|
|
|
26
28
|
waffles = Article.create! :title => 'Waffles', :user => user
|
|
27
29
|
index
|
|
28
30
|
|
|
29
|
-
Article.search('waffles', :conditions => {:title => 'pancakes'}).to_a.
|
|
30
|
-
|
|
31
|
+
expect(Article.search('waffles', :conditions => {:title => 'pancakes'}).to_a).
|
|
32
|
+
to eq([pancakes])
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
it "returns results with matches from concatenated columns in a field" do
|
|
34
36
|
book = Book.create! :title => 'Night Watch', :author => 'Terry Pratchett'
|
|
35
37
|
index
|
|
36
38
|
|
|
37
|
-
Book.search(:conditions => {:info => 'Night Pratchett'}).to_a.
|
|
38
|
-
|
|
39
|
+
expect(Book.search(:conditions => {:info => 'Night Pratchett'}).to_a).
|
|
40
|
+
to eq([book])
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
it "handles NULLs in concatenated fields" do
|
|
42
44
|
book = Book.create! :title => 'Night Watch'
|
|
43
45
|
index
|
|
44
46
|
|
|
45
|
-
Book.search(:conditions => {:info => 'Night Watch'}).to_a.
|
|
47
|
+
expect(Book.search(:conditions => {:info => 'Night Watch'}).to_a).to eq([book])
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
it "returns results with matches from file fields" do
|
|
@@ -52,6 +54,6 @@ describe 'Searching on fields', :live => true do
|
|
|
52
54
|
book = Book.create! :title => 'Accelerando', :blurb_file => file_path.to_s
|
|
53
55
|
index
|
|
54
56
|
|
|
55
|
-
Book.search('cyberpunk').to_a.
|
|
57
|
+
expect(Book.search('cyberpunk').to_a).to eq([book])
|
|
56
58
|
end
|
|
57
59
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching with filters', :live => true do
|
|
@@ -6,16 +8,16 @@ describe 'Searching with filters', :live => true do
|
|
|
6
8
|
waffles = Article.create! :title => 'Waffles', :published => false
|
|
7
9
|
index
|
|
8
10
|
|
|
9
|
-
Article.search(:with => {:published => true}).to_a.
|
|
11
|
+
expect(Article.search(:with => {:published => true}).to_a).to eq([pancakes])
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it "limits results by an array of values" do
|
|
13
|
-
gods = Book.create! :title => 'American Gods', :
|
|
14
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
15
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
15
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
16
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
17
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
16
18
|
index
|
|
17
19
|
|
|
18
|
-
Book.search(:with => {:
|
|
20
|
+
expect(Book.search(:with => {:publishing_year => [2001, 2005]}).to_a).to match_array([gods, boys])
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
it "limits results by a ranged filter" do
|
|
@@ -28,8 +30,8 @@ describe 'Searching with filters', :live => true do
|
|
|
28
30
|
grave.update_column :created_at, 1.day.ago
|
|
29
31
|
index
|
|
30
32
|
|
|
31
|
-
Book.search(:with => {:created_at => 6.days.ago..2.days.ago}).to_a.
|
|
32
|
-
|
|
33
|
+
expect(Book.search(:with => {:created_at => 6.days.ago..2.days.ago}).to_a).
|
|
34
|
+
to match_array([gods, boys])
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
it "limits results by exclusive filters on single values" do
|
|
@@ -37,16 +39,16 @@ describe 'Searching with filters', :live => true do
|
|
|
37
39
|
waffles = Article.create! :title => 'Waffles', :published => false
|
|
38
40
|
index
|
|
39
41
|
|
|
40
|
-
Article.search(:without => {:published => true}).to_a.
|
|
42
|
+
expect(Article.search(:without => {:published => true}).to_a).to eq([waffles])
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
it "limits results by exclusive filters on arrays of values" do
|
|
44
|
-
gods = Book.create! :title => 'American Gods', :
|
|
45
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
46
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
46
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
47
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
48
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
47
49
|
index
|
|
48
50
|
|
|
49
|
-
Book.search(:without => {:
|
|
51
|
+
expect(Book.search(:without => {:publishing_year => [2001, 2005]}).to_a).to eq([grave])
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
it "limits results by ranged filters on timestamp MVAs" do
|
|
@@ -64,9 +66,9 @@ describe 'Searching with filters', :live => true do
|
|
|
64
66
|
|
|
65
67
|
index
|
|
66
68
|
|
|
67
|
-
Article.search(
|
|
69
|
+
expect(Article.search(
|
|
68
70
|
:with => {:taggings_at => 1.days.ago..1.day.from_now}
|
|
69
|
-
).to_a.
|
|
71
|
+
).to_a).to eq([pancakes])
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
it "takes into account local timezones for timestamps" do
|
|
@@ -84,9 +86,9 @@ describe 'Searching with filters', :live => true do
|
|
|
84
86
|
|
|
85
87
|
index
|
|
86
88
|
|
|
87
|
-
Article.search(
|
|
89
|
+
expect(Article.search(
|
|
88
90
|
:with => {:taggings_at => 2.minutes.ago..Time.zone.now}
|
|
89
|
-
).to_a.
|
|
91
|
+
).to_a).to eq([pancakes])
|
|
90
92
|
end
|
|
91
93
|
|
|
92
94
|
it "limits results with MVAs having all of the given values" do
|
|
@@ -103,13 +105,13 @@ describe 'Searching with filters', :live => true do
|
|
|
103
105
|
index
|
|
104
106
|
|
|
105
107
|
articles = Article.search :with_all => {:tag_ids => [food.id, flat.id]}
|
|
106
|
-
articles.to_a.
|
|
108
|
+
expect(articles.to_a).to eq([pancakes])
|
|
107
109
|
end
|
|
108
110
|
|
|
109
111
|
it "limits results with MVAs that don't contain all the given values" do
|
|
110
112
|
# Matching results may have some of the given values, but cannot have all
|
|
111
113
|
# of them. Certainly an edge case.
|
|
112
|
-
|
|
114
|
+
skip "SphinxQL doesn't yet support OR in its WHERE clause"
|
|
113
115
|
|
|
114
116
|
pancakes = Article.create :title => 'Pancakes'
|
|
115
117
|
waffles = Article.create :title => 'Waffles'
|
|
@@ -124,7 +126,7 @@ describe 'Searching with filters', :live => true do
|
|
|
124
126
|
index
|
|
125
127
|
|
|
126
128
|
articles = Article.search :without_all => {:tag_ids => [food.id, flat.id]}
|
|
127
|
-
articles.to_a.
|
|
129
|
+
expect(articles.to_a).to eq([waffles])
|
|
128
130
|
end
|
|
129
131
|
|
|
130
132
|
it "limits results on real-time indices with multi-value integer attributes" do
|
|
@@ -139,6 +141,19 @@ describe 'Searching with filters', :live => true do
|
|
|
139
141
|
waffles.categories << food
|
|
140
142
|
|
|
141
143
|
products = Product.search :with => {:category_ids => [flat.id]}
|
|
142
|
-
products.to_a.
|
|
144
|
+
expect(products.to_a).to eq([pancakes])
|
|
143
145
|
end
|
|
146
|
+
|
|
147
|
+
it 'searches with real-time JSON attributes' do
|
|
148
|
+
pancakes = Product.create :name => 'Pancakes',
|
|
149
|
+
:options => {'lemon' => 1, 'sugar' => 1, :number => 3}
|
|
150
|
+
waffles = Product.create :name => 'Waffles',
|
|
151
|
+
:options => {'chocolate' => 1, 'sugar' => 1, :number => 1}
|
|
152
|
+
|
|
153
|
+
products = Product.search :with => {"options.lemon" => 1}
|
|
154
|
+
expect(products.to_a).to eq([pancakes])
|
|
155
|
+
|
|
156
|
+
products = Product.search :with => {"options.sugar" => 1}
|
|
157
|
+
expect(products.to_a).to match_array([pancakes, waffles])
|
|
158
|
+
end if JSONColumn.call
|
|
144
159
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching across STI models', :live => true do
|
|
@@ -6,7 +8,7 @@ describe 'Searching across STI models', :live => true do
|
|
|
6
8
|
duck = Bird.create :name => 'Duck'
|
|
7
9
|
index
|
|
8
10
|
|
|
9
|
-
Animal.search(:indices => ['animal_core']).to_a.
|
|
11
|
+
expect(Animal.search(:indices => ['animal_core']).to_a).to eq([platypus, duck])
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it "limits results based on subclasses" do
|
|
@@ -14,7 +16,7 @@ describe 'Searching across STI models', :live => true do
|
|
|
14
16
|
duck = Bird.create :name => 'Duck'
|
|
15
17
|
index
|
|
16
18
|
|
|
17
|
-
Bird.search(:indices => ['animal_core']).to_a.
|
|
19
|
+
expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck])
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
it "returns results for deeper subclasses when searching on their parents" do
|
|
@@ -23,7 +25,7 @@ describe 'Searching across STI models', :live => true do
|
|
|
23
25
|
emu = FlightlessBird.create :name => 'Emu'
|
|
24
26
|
index
|
|
25
27
|
|
|
26
|
-
Bird.search(:indices => ['animal_core']).to_a.
|
|
28
|
+
expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck, emu])
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
it "returns results for deeper subclasses" do
|
|
@@ -32,7 +34,7 @@ describe 'Searching across STI models', :live => true do
|
|
|
32
34
|
emu = FlightlessBird.create :name => 'Emu'
|
|
33
35
|
index
|
|
34
36
|
|
|
35
|
-
FlightlessBird.search(:indices => ['animal_core']).to_a.
|
|
37
|
+
expect(FlightlessBird.search(:indices => ['animal_core']).to_a).to eq([emu])
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
it "filters out sibling subclasses" do
|
|
@@ -41,7 +43,7 @@ describe 'Searching across STI models', :live => true do
|
|
|
41
43
|
otter = Mammal.create :name => 'Otter'
|
|
42
44
|
index
|
|
43
45
|
|
|
44
|
-
Bird.search(:indices => ['animal_core']).to_a.
|
|
46
|
+
expect(Bird.search(:indices => ['animal_core']).to_a).to eq([duck])
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
it "obeys :classes if supplied" do
|
|
@@ -50,18 +52,18 @@ describe 'Searching across STI models', :live => true do
|
|
|
50
52
|
emu = FlightlessBird.create :name => 'Emu'
|
|
51
53
|
index
|
|
52
54
|
|
|
53
|
-
Bird.search(
|
|
55
|
+
expect(Bird.search(
|
|
54
56
|
:indices => ['animal_core'],
|
|
55
57
|
:skip_sti => true,
|
|
56
58
|
:classes => [Bird, FlightlessBird]
|
|
57
|
-
).to_a.
|
|
59
|
+
).to_a).to eq([duck, emu])
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
it 'finds root objects when type is blank' do
|
|
61
63
|
animal = Animal.create :name => 'Animal', type: ''
|
|
62
64
|
index
|
|
63
65
|
|
|
64
|
-
Animal.search(:indices => ['animal_core']).to_a.
|
|
66
|
+
expect(Animal.search(:indices => ['animal_core']).to_a).to eq([animal])
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
it 'allows for indices on mid-hierarchy classes' do
|
|
@@ -69,6 +71,6 @@ describe 'Searching across STI models', :live => true do
|
|
|
69
71
|
emu = FlightlessBird.create :name => 'Emu'
|
|
70
72
|
index
|
|
71
73
|
|
|
72
|
-
Bird.search(:indices => ['bird_core']).to_a.
|
|
74
|
+
expect(Bird.search(:indices => ['bird_core']).to_a).to eq([duck, emu])
|
|
73
75
|
end
|
|
74
76
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
require 'acceptance/spec_helper'
|
|
3
5
|
|
|
4
6
|
describe 'Searching within a model', :live => true do
|
|
@@ -6,7 +8,7 @@ describe 'Searching within a model', :live => true do
|
|
|
6
8
|
article = Article.create! :title => 'Pancakes'
|
|
7
9
|
index
|
|
8
10
|
|
|
9
|
-
Article.search.first.
|
|
11
|
+
expect(Article.search.first).to eq(article)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it "returns results matching the given query" do
|
|
@@ -15,22 +17,22 @@ describe 'Searching within a model', :live => true do
|
|
|
15
17
|
index
|
|
16
18
|
|
|
17
19
|
articles = Article.search 'pancakes'
|
|
18
|
-
articles.
|
|
19
|
-
articles.
|
|
20
|
+
expect(articles).to include(pancakes)
|
|
21
|
+
expect(articles).not_to include(waffles)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
it "handles unicode characters" do
|
|
23
25
|
istanbul = City.create! :name => 'İstanbul'
|
|
24
26
|
index
|
|
25
27
|
|
|
26
|
-
City.search('İstanbul').to_a.
|
|
28
|
+
expect(City.search('İstanbul').to_a).to eq([istanbul])
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
it "will star provided queries on request" do
|
|
30
32
|
article = Article.create! :title => 'Pancakes'
|
|
31
33
|
index
|
|
32
34
|
|
|
33
|
-
Article.search('cake', :star => true).first.
|
|
35
|
+
expect(Article.search('cake', :star => true).first).to eq(article)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
it "allows for searching on specific indices" do
|
|
@@ -38,7 +40,7 @@ describe 'Searching within a model', :live => true do
|
|
|
38
40
|
index
|
|
39
41
|
|
|
40
42
|
articles = Article.search('pancake', :indices => ['stemmed_article_core'])
|
|
41
|
-
articles.to_a.
|
|
43
|
+
expect(articles.to_a).to eq([article])
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
it "allows for searching on distributed indices" do
|
|
@@ -46,38 +48,63 @@ describe 'Searching within a model', :live => true do
|
|
|
46
48
|
index
|
|
47
49
|
|
|
48
50
|
articles = Article.search('pancake', :indices => ['article'])
|
|
49
|
-
articles.to_a.
|
|
51
|
+
expect(articles.to_a).to eq([article])
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
it "can search on namespaced models" do
|
|
53
55
|
person = Admin::Person.create :name => 'James Bond'
|
|
54
56
|
index
|
|
55
57
|
|
|
56
|
-
Admin::Person.search('Bond').to_a.
|
|
58
|
+
expect(Admin::Person.search('Bond').to_a).to eq([person])
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
it "raises an error if searching through an ActiveRecord scope" do
|
|
60
|
-
|
|
62
|
+
expect {
|
|
61
63
|
City.ordered.search
|
|
62
|
-
}.
|
|
64
|
+
}.to raise_error(ThinkingSphinx::MixedScopesError)
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
it "does not raise an error when searching with a default ActiveRecord scope" do
|
|
66
|
-
|
|
68
|
+
expect {
|
|
67
69
|
User.search
|
|
68
|
-
}.
|
|
70
|
+
}.not_to raise_error
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
it "raises an error when searching with default and applied AR scopes" do
|
|
72
|
-
|
|
74
|
+
expect {
|
|
73
75
|
User.recent.search
|
|
74
|
-
}.
|
|
76
|
+
}.to raise_error(ThinkingSphinx::MixedScopesError)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
it "raises an error if the model has no indices defined" do
|
|
78
|
-
|
|
80
|
+
expect {
|
|
79
81
|
Category.search.to_a
|
|
80
|
-
}.
|
|
82
|
+
}.to raise_error(ThinkingSphinx::NoIndicesError)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "handles models with alternative id columns" do
|
|
86
|
+
album = Album.create! :name => 'The Seldom Seen Kid', :artist => 'Elbow'
|
|
87
|
+
index
|
|
88
|
+
|
|
89
|
+
expect(Album.search(:indices => ['album_core', 'album_delta']).first).
|
|
90
|
+
to eq(album)
|
|
91
|
+
|
|
92
|
+
expect(Album.search(:indices => ['album_real_core']).first).
|
|
93
|
+
to eq(album)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "is available via a sphinx-prefixed method" do
|
|
97
|
+
article = Article.create! :title => 'Pancakes'
|
|
98
|
+
index
|
|
99
|
+
|
|
100
|
+
expect(Article.sphinx_search.first).to eq(article)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "has a 'none' default scope" do
|
|
104
|
+
article = Article.create! :title => 'Pancakes'
|
|
105
|
+
index
|
|
106
|
+
|
|
107
|
+
expect(Article.search_none).to be_empty
|
|
81
108
|
end
|
|
82
109
|
end
|
|
83
110
|
|
|
@@ -85,6 +112,6 @@ describe 'Searching within a model with a realtime index', :live => true do
|
|
|
85
112
|
it "returns results" do
|
|
86
113
|
product = Product.create! :name => 'Widget'
|
|
87
114
|
|
|
88
|
-
Product.search.first.
|
|
115
|
+
expect(Product.search.first).to eq(product)
|
|
89
116
|
end
|
|
90
117
|
end
|
|
@@ -1,48 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Sorting search results', :live => true do
|
|
4
6
|
it "sorts by a given clause" do
|
|
5
|
-
gods = Book.create! :title => 'American Gods', :
|
|
6
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
7
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
7
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
8
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
9
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
8
10
|
index
|
|
9
11
|
|
|
10
|
-
Book.search(:order => '
|
|
12
|
+
expect(Book.search(:order => 'publishing_year ASC').to_a).to eq([gods, boys, grave])
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
it "sorts by a given attribute in ascending order" do
|
|
14
|
-
gods = Book.create! :title => 'American Gods', :
|
|
15
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
16
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
16
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
17
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
18
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
17
19
|
index
|
|
18
20
|
|
|
19
|
-
Book.search(:order => :
|
|
21
|
+
expect(Book.search(:order => :publishing_year).to_a).to eq([gods, boys, grave])
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
it "sorts by a given sortable field" do
|
|
23
|
-
gods = Book.create! :title => 'American Gods', :
|
|
24
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
25
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
25
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
26
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
27
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
26
28
|
index
|
|
27
29
|
|
|
28
|
-
Book.search(:order => :title).to_a.
|
|
30
|
+
expect(Book.search(:order => :title).to_a).to eq([gods, boys, grave])
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
it "sorts by a given sortable field with real-time indices" do
|
|
32
34
|
widgets = Product.create! :name => 'Widgets'
|
|
33
35
|
gadgets = Product.create! :name => 'Gadgets'
|
|
34
36
|
|
|
35
|
-
Product.search(:order => "name_sort ASC").to_a.
|
|
37
|
+
expect(Product.search(:order => "name_sort ASC").to_a).to eq([gadgets, widgets])
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
it "can sort with a provided expression" do
|
|
39
|
-
gods = Book.create! :title => 'American Gods', :
|
|
40
|
-
grave = Book.create! :title => 'The Graveyard Book', :
|
|
41
|
-
boys = Book.create! :title => 'Anansi Boys', :
|
|
41
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
42
|
+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
|
|
43
|
+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
|
|
42
44
|
index
|
|
43
45
|
|
|
44
|
-
Book.search(
|
|
45
|
-
:select => '*,
|
|
46
|
-
).to_a.
|
|
46
|
+
expect(Book.search(
|
|
47
|
+
:select => '*, publishing_year MOD 2004 as mod_year', :order => 'mod_year ASC'
|
|
48
|
+
).to_a).to eq([boys, grave, gods])
|
|
47
49
|
end
|
|
48
50
|
end
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
root = File.expand_path File.dirname(__FILE__)
|
|
4
6
|
Dir["#{root}/support/**/*.rb"].each { |file| require file }
|
|
5
|
-
|
|
6
|
-
if ENV['SPHINX_VERSION'].try :[], /2.0.\d/
|
|
7
|
-
ThinkingSphinx::SphinxQL.variables!
|
|
8
|
-
|
|
9
|
-
ThinkingSphinx::Middlewares::DEFAULT.insert_after(
|
|
10
|
-
ThinkingSphinx::Middlewares::Inquirer,
|
|
11
|
-
ThinkingSphinx::Middlewares::UTF8
|
|
12
|
-
)
|
|
13
|
-
ThinkingSphinx::Middlewares::RAW_ONLY.insert_after(
|
|
14
|
-
ThinkingSphinx::Middlewares::Inquirer,
|
|
15
|
-
ThinkingSphinx::Middlewares::UTF8
|
|
16
|
-
)
|
|
17
|
-
end
|