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
data/lib/thinking_sphinx/test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Test
|
|
2
4
|
def self.init(suppress_delta_output = true)
|
|
3
5
|
FileUtils.mkdir_p config.indices_location
|
|
@@ -40,7 +42,7 @@ class ThinkingSphinx::Test
|
|
|
40
42
|
config.indices_location,
|
|
41
43
|
config.searchd.binlog_path
|
|
42
44
|
].each do |path|
|
|
43
|
-
FileUtils.
|
|
45
|
+
FileUtils.rm_rf(path) if File.exist?(path)
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
|
data/lib/thinking_sphinx/utf8.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ThinkingSphinx::Wildcard
|
|
2
4
|
DEFAULT_TOKEN = /\p{Word}+/
|
|
3
5
|
|
|
@@ -14,7 +16,7 @@ class ThinkingSphinx::Wildcard
|
|
|
14
16
|
query.gsub(extended_pattern) do
|
|
15
17
|
pre, proper, post = $`, $&, $'
|
|
16
18
|
# E.g. "@foo", "/2", "~3", but not as part of a token pattern
|
|
17
|
-
is_operator = pre
|
|
19
|
+
is_operator = pre.match(%r{@$}) ||
|
|
18
20
|
pre.match(%r{([^\\]+|\A)[~/]\Z}) ||
|
|
19
21
|
pre.match(%r{(\W|^)@\([^\)]*$})
|
|
20
22
|
# E.g. "foo bar", with quotes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ThinkingSphinx::WithOutput
|
|
4
|
+
def initialize(configuration, options = {}, stream = STDOUT)
|
|
5
|
+
@configuration = configuration
|
|
6
|
+
@options = options
|
|
7
|
+
@stream = stream
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
attr_reader :configuration, :options, :stream
|
|
13
|
+
end
|
data/lib/thinking_sphinx.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
if RUBY_PLATFORM == 'java'
|
|
2
4
|
require 'java'
|
|
3
5
|
require 'jdbc/mysql'
|
|
@@ -16,7 +18,7 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|
|
16
18
|
|
|
17
19
|
module ThinkingSphinx
|
|
18
20
|
def self.count(query = '', options = {})
|
|
19
|
-
|
|
21
|
+
search_for_ids(query, options).total_entries
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def self.facets(query = '', options = {})
|
|
@@ -32,22 +34,45 @@ module ThinkingSphinx
|
|
|
32
34
|
ThinkingSphinx::Search::Merger.new(search).merge! nil, :ids_only => true
|
|
33
35
|
end
|
|
34
36
|
|
|
37
|
+
def self.none
|
|
38
|
+
ThinkingSphinx::Search.new nil, :none => true
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
def self.before_index_hooks
|
|
36
42
|
@before_index_hooks
|
|
37
43
|
end
|
|
38
44
|
|
|
39
45
|
@before_index_hooks = []
|
|
40
46
|
|
|
47
|
+
def self.output
|
|
48
|
+
@output
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
@output = STDOUT
|
|
52
|
+
|
|
53
|
+
def self.rake_interface
|
|
54
|
+
@rake_interface ||= ThinkingSphinx::RakeInterface
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.rake_interface=(interface)
|
|
58
|
+
@rake_interface = interface
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
module Hooks; end
|
|
62
|
+
module IndexingStrategies; end
|
|
41
63
|
module Subscribers; end
|
|
42
64
|
end
|
|
43
65
|
|
|
44
66
|
# Core
|
|
67
|
+
require 'thinking_sphinx/attribute_types'
|
|
45
68
|
require 'thinking_sphinx/batched_search'
|
|
46
69
|
require 'thinking_sphinx/callbacks'
|
|
47
70
|
require 'thinking_sphinx/core'
|
|
71
|
+
require 'thinking_sphinx/with_output'
|
|
72
|
+
require 'thinking_sphinx/commander'
|
|
73
|
+
require 'thinking_sphinx/commands'
|
|
48
74
|
require 'thinking_sphinx/configuration'
|
|
49
75
|
require 'thinking_sphinx/connection'
|
|
50
|
-
require 'thinking_sphinx/controller'
|
|
51
76
|
require 'thinking_sphinx/deletion'
|
|
52
77
|
require 'thinking_sphinx/errors'
|
|
53
78
|
require 'thinking_sphinx/excerpter'
|
|
@@ -56,25 +81,31 @@ require 'thinking_sphinx/facet_search'
|
|
|
56
81
|
require 'thinking_sphinx/float_formatter'
|
|
57
82
|
require 'thinking_sphinx/frameworks'
|
|
58
83
|
require 'thinking_sphinx/guard'
|
|
84
|
+
require 'thinking_sphinx/hooks/guard_presence'
|
|
59
85
|
require 'thinking_sphinx/index'
|
|
86
|
+
require 'thinking_sphinx/indexing_strategies/all_at_once'
|
|
87
|
+
require 'thinking_sphinx/indexing_strategies/one_at_a_time'
|
|
60
88
|
require 'thinking_sphinx/index_set'
|
|
89
|
+
require 'thinking_sphinx/interfaces'
|
|
61
90
|
require 'thinking_sphinx/masks'
|
|
62
91
|
require 'thinking_sphinx/middlewares'
|
|
63
92
|
require 'thinking_sphinx/panes'
|
|
93
|
+
require 'thinking_sphinx/processor'
|
|
64
94
|
require 'thinking_sphinx/query'
|
|
65
95
|
require 'thinking_sphinx/rake_interface'
|
|
66
96
|
require 'thinking_sphinx/scopes'
|
|
67
97
|
require 'thinking_sphinx/search'
|
|
68
|
-
require 'thinking_sphinx/
|
|
98
|
+
require 'thinking_sphinx/settings'
|
|
69
99
|
require 'thinking_sphinx/subscribers/populator_subscriber'
|
|
70
100
|
require 'thinking_sphinx/test'
|
|
71
101
|
require 'thinking_sphinx/utf8'
|
|
72
102
|
require 'thinking_sphinx/wildcard'
|
|
73
103
|
# Extended
|
|
74
|
-
require 'thinking_sphinx/active_record'
|
|
75
104
|
require 'thinking_sphinx/deltas'
|
|
76
105
|
require 'thinking_sphinx/distributed'
|
|
77
106
|
require 'thinking_sphinx/logger'
|
|
78
107
|
require 'thinking_sphinx/real_time'
|
|
79
108
|
|
|
80
109
|
require 'thinking_sphinx/railtie' if defined?(Rails::Railtie)
|
|
110
|
+
|
|
111
|
+
ThinkingSphinx.before_index_hooks << ThinkingSphinx::Hooks::GuardPresence
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Scoping association search calls by foreign keys', :live => true do
|
|
@@ -9,7 +11,7 @@ describe 'Scoping association search calls by foreign keys', :live => true do
|
|
|
9
11
|
dublin = Article.create :title => 'Guide to Dublin', :user => paul
|
|
10
12
|
index
|
|
11
13
|
|
|
12
|
-
pat.articles.search('Guide').to_a.
|
|
14
|
+
expect(pat.articles.search('Guide').to_a).to eq([melbourne])
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
it "limits id-only results to those matching the foreign key" do
|
|
@@ -19,7 +21,7 @@ describe 'Scoping association search calls by foreign keys', :live => true do
|
|
|
19
21
|
dublin = Article.create :title => 'Guide to Dublin', :user => paul
|
|
20
22
|
index
|
|
21
23
|
|
|
22
|
-
pat.articles.search_for_ids('Guide').to_a.
|
|
24
|
+
expect(pat.articles.search_for_ids('Guide').to_a).to eq([melbourne.id])
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
@@ -31,7 +33,7 @@ describe 'Scoping association search calls by foreign keys', :live => true do
|
|
|
31
33
|
audi = Manufacturer.create :name => 'Audi'
|
|
32
34
|
r_eight = Car.create :name => 'R8 Spyder', :manufacturer => audi
|
|
33
35
|
|
|
34
|
-
porsche.cars.search('Spyder').to_a.
|
|
36
|
+
expect(porsche.cars.search('Spyder').to_a).to eq([spyder])
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
it "limits id-only results to those matching the foreign key" do
|
|
@@ -41,7 +43,7 @@ describe 'Scoping association search calls by foreign keys', :live => true do
|
|
|
41
43
|
audi = Manufacturer.create :name => 'Audi'
|
|
42
44
|
r_eight = Car.create :name => 'R8 Spyder', :manufacturer => audi
|
|
43
45
|
|
|
44
|
-
porsche.cars.search_for_ids('Spyder').to_a.
|
|
46
|
+
expect(porsche.cars.search_for_ids('Spyder').to_a).to eq([spyder.id])
|
|
45
47
|
end
|
|
46
48
|
end
|
|
47
49
|
|
|
@@ -57,7 +59,7 @@ describe 'Scoping association search calls by foreign keys', :live => true do
|
|
|
57
59
|
pancakes.categories << flat
|
|
58
60
|
waffles.categories << food
|
|
59
61
|
|
|
60
|
-
flat.products.search('Low').to_a.
|
|
62
|
+
expect(flat.products.search('Low').to_a).to eq([pancakes])
|
|
61
63
|
end
|
|
62
64
|
end
|
|
63
65
|
end
|
|
@@ -1,41 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Accessing attributes directly via search results', :live => true do
|
|
4
6
|
it "allows access to attribute values" do
|
|
5
|
-
Book.create! :title => 'American Gods', :
|
|
7
|
+
Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
6
8
|
index
|
|
7
9
|
|
|
8
10
|
search = Book.search('gods')
|
|
9
11
|
search.context[:panes] << ThinkingSphinx::Panes::AttributesPane
|
|
10
12
|
|
|
11
|
-
search.first.sphinx_attributes['
|
|
13
|
+
expect(search.first.sphinx_attributes['publishing_year']).to eq(2001)
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "provides direct access to the search weight/relevance scores" do
|
|
15
|
-
Book.create! :title => 'American Gods', :
|
|
17
|
+
Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
16
18
|
index
|
|
17
19
|
|
|
18
|
-
search = Book.search 'gods',
|
|
19
|
-
|
|
20
|
+
search = Book.search 'gods', :select => "*, weight()"
|
|
21
|
+
search.context[:panes] << ThinkingSphinx::Panes::WeightPane
|
|
22
|
+
|
|
23
|
+
if ENV["SPHINX_ENGINE"] == "sphinx" && ENV["SPHINX_VERSION"].to_f > 3.3
|
|
24
|
+
expect(search.first.weight).to eq(20_000.0)
|
|
25
|
+
else
|
|
26
|
+
expect(search.first.weight).to eq(2500)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "provides direct access to the weight with alternative primary keys" do
|
|
31
|
+
album = Album.create! :name => 'Sing to the Moon', :artist => 'Laura Mvula'
|
|
32
|
+
|
|
33
|
+
search = Album.search 'sing', :select => "*, weight()"
|
|
20
34
|
search.context[:panes] << ThinkingSphinx::Panes::WeightPane
|
|
21
35
|
|
|
22
|
-
search.first.weight.
|
|
36
|
+
expect(search.first.weight).to be >= 1000
|
|
23
37
|
end
|
|
24
38
|
|
|
25
39
|
it "can enumerate with the weight" do
|
|
26
|
-
gods = Book.create! :title => 'American Gods', :
|
|
40
|
+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
27
41
|
index
|
|
28
42
|
|
|
29
|
-
search = Book.search 'gods',
|
|
30
|
-
:select => "*, #{ThinkingSphinx::SphinxQL.weight[:select]}"
|
|
43
|
+
search = Book.search 'gods', :select => "*, weight()"
|
|
31
44
|
search.masks << ThinkingSphinx::Masks::WeightEnumeratorMask
|
|
32
45
|
|
|
33
|
-
|
|
46
|
+
if ENV["SPHINX_ENGINE"] == "sphinx" && ENV["SPHINX_VERSION"].to_f > 3.3
|
|
47
|
+
expectations = [[gods, 20_000.0]]
|
|
48
|
+
else
|
|
49
|
+
expectations = [[gods, 2500]]
|
|
50
|
+
end
|
|
34
51
|
search.each_with_weight do |result, weight|
|
|
35
52
|
expectation = expectations.shift
|
|
36
53
|
|
|
37
|
-
result.
|
|
38
|
-
weight.
|
|
54
|
+
expect(result).to eq(expectation.first)
|
|
55
|
+
expect(weight).to eq(expectation.last)
|
|
39
56
|
end
|
|
40
57
|
end
|
|
41
58
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Update attributes automatically where possible', :live => true do
|
|
@@ -5,12 +7,12 @@ describe 'Update attributes automatically where possible', :live => true do
|
|
|
5
7
|
article = Article.create :title => 'Pancakes', :published => false
|
|
6
8
|
index
|
|
7
9
|
|
|
8
|
-
Article.search('pancakes', :with => {:published => true}).
|
|
10
|
+
expect(Article.search('pancakes', :with => {:published => true})).to be_empty
|
|
9
11
|
|
|
10
12
|
article.published = true
|
|
11
13
|
article.save
|
|
12
14
|
|
|
13
|
-
Article.search('pancakes', :with => {:published => true}).to_a
|
|
14
|
-
.
|
|
15
|
+
expect(Article.search('pancakes', :with => {:published => true}).to_a)
|
|
16
|
+
.to eq([article])
|
|
15
17
|
end
|
|
16
18
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Executing multiple searches in one Sphinx call', :live => true do
|
|
@@ -12,10 +14,10 @@ describe 'Executing multiple searches in one Sphinx call', :live => true do
|
|
|
12
14
|
|
|
13
15
|
batch.populate
|
|
14
16
|
|
|
15
|
-
batch.searches.first.
|
|
16
|
-
batch.searches.first.
|
|
17
|
+
expect(batch.searches.first).to include(pancakes)
|
|
18
|
+
expect(batch.searches.first).not_to include(waffles)
|
|
17
19
|
|
|
18
|
-
batch.searches.last.
|
|
19
|
-
batch.searches.last.
|
|
20
|
+
expect(batch.searches.last).to include(waffles)
|
|
21
|
+
expect(batch.searches.last).not_to include(pancakes)
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe '64 bit integer support' do
|
|
@@ -21,17 +23,17 @@ describe '64 bit integer support' do
|
|
|
21
23
|
[small_index, large_index, real_time_index]
|
|
22
24
|
).reconcile
|
|
23
25
|
|
|
24
|
-
large_index.sources.first.attributes.detect { |attribute|
|
|
26
|
+
expect(large_index.sources.first.attributes.detect { |attribute|
|
|
25
27
|
attribute.name == 'sphinx_internal_id'
|
|
26
|
-
}.type.
|
|
28
|
+
}.type).to eq(:bigint)
|
|
27
29
|
|
|
28
|
-
small_index.sources.first.attributes.detect { |attribute|
|
|
30
|
+
expect(small_index.sources.first.attributes.detect { |attribute|
|
|
29
31
|
attribute.name == 'sphinx_internal_id'
|
|
30
|
-
}.type.
|
|
32
|
+
}.type).to eq(:bigint)
|
|
31
33
|
|
|
32
|
-
real_time_index.attributes.detect { |attribute|
|
|
34
|
+
expect(real_time_index.attributes.detect { |attribute|
|
|
33
35
|
attribute.name == 'sphinx_internal_id'
|
|
34
|
-
}.type.
|
|
36
|
+
}.type).to eq(:bigint)
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -50,7 +52,7 @@ describe '64 bit document ids', :live => true do
|
|
|
50
52
|
context 'with Real-Time' do
|
|
51
53
|
it 'handles large 32 bit integers with an offset multiplier' do
|
|
52
54
|
product = Product.create! :name => "Widget"
|
|
53
|
-
product.
|
|
55
|
+
product.update :id => 980190962
|
|
54
56
|
expect(
|
|
55
57
|
Product.search('widget', :indices => ['product_core']).to_a
|
|
56
58
|
).to eq([product])
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require 'acceptance/spec_helper'
|
|
4
5
|
|
|
5
6
|
describe 'Accessing excerpts for methods on a search result', :live => true do
|
|
6
7
|
it "returns excerpts for a given method" do
|
|
7
|
-
Book.create! :title => 'American Gods', :
|
|
8
|
+
Book.create! :title => 'American Gods', :publishing_year => 2001
|
|
8
9
|
index
|
|
9
10
|
|
|
10
11
|
search = Book.search('gods')
|
|
11
12
|
search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
|
|
12
13
|
|
|
13
|
-
search.first.excerpts.title.
|
|
14
|
-
|
|
14
|
+
expect(search.first.excerpts.title).
|
|
15
|
+
to eq('American <span class="match">Gods</span>')
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
it "handles UTF-8 text for excerpts" do
|
|
18
|
-
Book.create! :title => 'Война и миръ', :
|
|
19
|
+
Book.create! :title => 'Война и миръ', :publishing_year => 1869
|
|
19
20
|
index
|
|
20
21
|
|
|
21
22
|
search = Book.search 'миръ'
|
|
22
23
|
search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
|
|
23
24
|
|
|
24
|
-
search.first.excerpts.title.
|
|
25
|
-
|
|
25
|
+
expect(search.first.excerpts.title).
|
|
26
|
+
to eq('Война и <span class="match">миръ</span>')
|
|
26
27
|
end if ENV['SPHINX_VERSION'].try :[], /2.2.\d/
|
|
27
28
|
|
|
28
29
|
it "does not include class names in excerpts" do
|
|
@@ -32,8 +33,8 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
|
|
|
32
33
|
search = Book.search('graveyard')
|
|
33
34
|
search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
|
|
34
35
|
|
|
35
|
-
search.first.excerpts.title.
|
|
36
|
-
|
|
36
|
+
expect(search.first.excerpts.title).
|
|
37
|
+
to eq('The <span class="match">Graveyard</span> Book')
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
it "respects the star option with queries" do
|
|
@@ -43,7 +44,7 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
|
|
|
43
44
|
search = Article.search('thin', :star => true)
|
|
44
45
|
search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane
|
|
45
46
|
|
|
46
|
-
search.first.excerpts.title.
|
|
47
|
-
|
|
47
|
+
expect(search.first.excerpts.title).
|
|
48
|
+
to eq('<span class="match">Something</span>')
|
|
48
49
|
end
|
|
49
50
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require 'acceptance/spec_helper'
|
|
4
5
|
|
|
@@ -16,9 +17,9 @@ describe 'Faceted searching', :live => true do
|
|
|
16
17
|
Tee.create! :colour => green
|
|
17
18
|
index
|
|
18
19
|
|
|
19
|
-
Tee.facets.to_hash[:colour_id].
|
|
20
|
+
expect(Tee.facets.to_hash[:colour_id]).to eq({
|
|
20
21
|
blue.id => 2, red.id => 1, green.id => 3
|
|
21
|
-
}
|
|
22
|
+
})
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it "provides facet breakdowns across classes" do
|
|
@@ -28,11 +29,9 @@ describe 'Faceted searching', :live => true do
|
|
|
28
29
|
Article.create!
|
|
29
30
|
index
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'Tee' => 2, 'City' => 1, 'Article' => article_count
|
|
35
|
-
}
|
|
32
|
+
expect(ThinkingSphinx.facets.to_hash[:class]).to eq({
|
|
33
|
+
'Tee' => 2, 'City' => 1, 'Article' => 1
|
|
34
|
+
})
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
it "handles field facets" do
|
|
@@ -42,9 +41,9 @@ describe 'Faceted searching', :live => true do
|
|
|
42
41
|
Book.create! :title => '1Q84', :author => '村上 春樹'
|
|
43
42
|
index
|
|
44
43
|
|
|
45
|
-
Book.facets.to_hash[:author].
|
|
44
|
+
expect(Book.facets.to_hash[:author]).to eq({
|
|
46
45
|
'Neil Gaiman' => 2, 'Terry Pratchett' => 1, '村上 春樹' => 1
|
|
47
|
-
}
|
|
46
|
+
})
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
it "handles MVA facets" do
|
|
@@ -62,9 +61,9 @@ describe 'Faceted searching', :live => true do
|
|
|
62
61
|
:tag => pancakes
|
|
63
62
|
index
|
|
64
63
|
|
|
65
|
-
User.facets.to_hash[:tag_ids].
|
|
64
|
+
expect(User.facets.to_hash[:tag_ids]).to eq({
|
|
66
65
|
pancakes.id => 2, waffles.id => 1
|
|
67
|
-
}
|
|
66
|
+
})
|
|
68
67
|
end
|
|
69
68
|
|
|
70
69
|
it "can filter on integer facet results" do
|
|
@@ -76,7 +75,7 @@ describe 'Faceted searching', :live => true do
|
|
|
76
75
|
r1 = Tee.create! :colour => red
|
|
77
76
|
index
|
|
78
77
|
|
|
79
|
-
Tee.facets.for(:colour_id => blue.id).to_a.
|
|
78
|
+
expect(Tee.facets.for(:colour_id => blue.id).to_a).to eq([b1, b2])
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
it "can filter on MVA facet results" do
|
|
@@ -91,7 +90,7 @@ describe 'Faceted searching', :live => true do
|
|
|
91
90
|
Tagging.create! :article => Article.create!(:user => u2), :tag => pancakes
|
|
92
91
|
index
|
|
93
92
|
|
|
94
|
-
User.facets.for(:tag_ids => waffles.id).to_a.
|
|
93
|
+
expect(User.facets.for(:tag_ids => waffles.id).to_a).to eq([u1])
|
|
95
94
|
end
|
|
96
95
|
|
|
97
96
|
it "can filter on string facet results" do
|
|
@@ -100,7 +99,7 @@ describe 'Faceted searching', :live => true do
|
|
|
100
99
|
snuff = Book.create! :title => 'Snuff', :author => 'Terry Pratchett'
|
|
101
100
|
index
|
|
102
101
|
|
|
103
|
-
Book.facets.for(:author => 'Neil Gaiman').to_a.
|
|
102
|
+
expect(Book.facets.for(:author => 'Neil Gaiman').to_a).to eq([gods, boys])
|
|
104
103
|
end
|
|
105
104
|
|
|
106
105
|
it "allows enumeration" do
|
|
@@ -119,10 +118,24 @@ describe 'Faceted searching', :live => true do
|
|
|
119
118
|
[:class, {'Tee' => 3}]
|
|
120
119
|
]
|
|
121
120
|
Tee.facets.each do |facet, hash|
|
|
122
|
-
facet.
|
|
123
|
-
hash.
|
|
121
|
+
expect(facet).to eq(expectations[calls].first)
|
|
122
|
+
expect(hash).to eq(expectations[calls].last)
|
|
124
123
|
|
|
125
124
|
calls += 1
|
|
126
125
|
end
|
|
127
126
|
end
|
|
127
|
+
|
|
128
|
+
it "can be called on distributed indices" do
|
|
129
|
+
blue = Colour.create! :name => 'blue'
|
|
130
|
+
green = Colour.create! :name => 'green'
|
|
131
|
+
|
|
132
|
+
Tee.create! :colour => blue
|
|
133
|
+
Tee.create! :colour => blue
|
|
134
|
+
Tee.create! :colour => green
|
|
135
|
+
index
|
|
136
|
+
|
|
137
|
+
expect(Tee.facets(:indices => ["tee"]).to_hash[:colour_id]).to eq({
|
|
138
|
+
blue.id => 2, green.id => 1
|
|
139
|
+
})
|
|
140
|
+
end
|
|
128
141
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'acceptance/spec_helper'
|
|
2
4
|
|
|
3
5
|
describe 'Searching by latitude and longitude', :live => true do
|
|
@@ -7,8 +9,8 @@ describe 'Searching by latitude and longitude', :live => true do
|
|
|
7
9
|
bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
|
|
8
10
|
index
|
|
9
11
|
|
|
10
|
-
City.search(:geo => [-0.616241, 2.602712], :order => 'geodist ASC').
|
|
11
|
-
to_a.
|
|
12
|
+
expect(City.search(:geo => [-0.616241, 2.602712], :order => 'geodist ASC').
|
|
13
|
+
to_a).to eq([syd, mel, bri])
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it "filters by distance" do
|
|
@@ -17,10 +19,10 @@ describe 'Searching by latitude and longitude', :live => true do
|
|
|
17
19
|
bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
|
|
18
20
|
index
|
|
19
21
|
|
|
20
|
-
City.search(
|
|
22
|
+
expect(City.search(
|
|
21
23
|
:geo => [-0.616241, 2.602712],
|
|
22
24
|
:with => {:geodist => 0.0..470_000.0}
|
|
23
|
-
).to_a.
|
|
25
|
+
).to_a).to eq([mel, syd])
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it "provides the distance for each search result" do
|
|
@@ -30,16 +32,26 @@ describe 'Searching by latitude and longitude', :live => true do
|
|
|
30
32
|
index
|
|
31
33
|
|
|
32
34
|
cities = City.search(:geo => [-0.616241, 2.602712], :order => 'geodist ASC')
|
|
33
|
-
if ENV
|
|
35
|
+
if ENV.fetch('SPHINX_VERSION', '2.1.2').to_f > 2.1
|
|
34
36
|
expected = {:mysql => 249907.171875, :postgresql => 249912.03125}
|
|
35
37
|
else
|
|
36
38
|
expected = {:mysql => 250326.906250, :postgresql => 250331.234375}
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
adapter = nil
|
|
42
|
+
|
|
43
|
+
if ActiveRecord::VERSION::STRING.to_f > 6.0
|
|
44
|
+
adapter = ActiveRecord::Base.configurations.configs_for.first.adapter
|
|
45
|
+
elsif ActiveRecord::VERSION::STRING.to_f > 5.2
|
|
46
|
+
adapter = ActiveRecord::Base.configurations.configs_for.first.config["adapter"]
|
|
47
|
+
else
|
|
48
|
+
adapter = ActiveRecord::Base.configurations['test']['adapter']
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if adapter[/postgres/]
|
|
52
|
+
expect(cities.first.geodist).to be_within(0.01).of(expected[:postgresql])
|
|
41
53
|
else # mysql
|
|
42
|
-
cities.first.geodist.
|
|
54
|
+
expect(cities.first.geodist).to be_within(0.01).of(expected[:mysql])
|
|
43
55
|
end
|
|
44
56
|
end
|
|
45
57
|
|
|
@@ -49,10 +61,10 @@ describe 'Searching by latitude and longitude', :live => true do
|
|
|
49
61
|
bri = City.create :name => 'Brisbane', :lat => -0.4794031, :lng => 2.670838
|
|
50
62
|
index
|
|
51
63
|
|
|
52
|
-
City.search(
|
|
64
|
+
expect(City.search(
|
|
53
65
|
:geo => [-0.616241, 2.602712],
|
|
54
66
|
:with => {:geodist => 0.0..470_000.0},
|
|
55
67
|
:select => "*, geodist as custom_weight"
|
|
56
|
-
).to_a.
|
|
68
|
+
).to_a).to eq([mel, syd])
|
|
57
69
|
end
|
|
58
70
|
end
|