algolia 2.3.4 → 3.0.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -93
- data/Gemfile +1 -14
- data/Gemfile.lock +64 -0
- data/README.md +4 -6
- data/Rakefile +0 -39
- data/algolia.gemspec +24 -39
- data/lib/algolia/api/abtesting_client.rb +418 -0
- data/lib/algolia/api/analytics_client.rb +1294 -0
- data/lib/algolia/api/ingestion_client.rb +1659 -0
- data/lib/algolia/api/insights_client.rb +252 -0
- data/lib/algolia/api/monitoring_client.rb +555 -0
- data/lib/algolia/api/personalization_client.rb +365 -0
- data/lib/algolia/api/query_suggestions_client.rb +491 -0
- data/lib/algolia/api/recommend_client.rb +460 -0
- data/lib/algolia/api/search_client.rb +2723 -0
- data/lib/algolia/api_client.rb +153 -0
- data/lib/algolia/api_error.rb +48 -0
- data/lib/algolia/configuration.rb +41 -0
- data/lib/algolia/logger_helper.rb +1 -1
- data/lib/algolia/models/abtesting/ab_test.rb +332 -0
- data/lib/algolia/models/abtesting/ab_test_response.rb +219 -0
- data/lib/algolia/models/abtesting/ab_tests_variant.rb +217 -0
- data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +236 -0
- data/lib/algolia/models/abtesting/add_ab_tests_request.rb +239 -0
- data/lib/algolia/models/abtesting/add_ab_tests_variant.rb +96 -0
- data/lib/algolia/models/abtesting/currencies_value.rb +223 -0
- data/lib/algolia/models/abtesting/custom_search_params.rb +195 -0
- data/lib/algolia/models/abtesting/error_base.rb +196 -0
- data/lib/algolia/models/abtesting/filter_effects.rb +202 -0
- data/lib/algolia/models/abtesting/filter_effects_empty_search.rb +204 -0
- data/lib/algolia/models/abtesting/filter_effects_outliers.rb +204 -0
- data/lib/algolia/models/abtesting/list_ab_tests_response.rb +221 -0
- data/lib/algolia/models/abtesting/variant.rb +399 -0
- data/lib/algolia/models/analytics/average_click_event.rb +219 -0
- data/lib/algolia/models/analytics/click_position.rb +209 -0
- data/lib/algolia/models/analytics/click_through_rate_event.rb +249 -0
- data/lib/algolia/models/analytics/conversion_rate_event.rb +249 -0
- data/lib/algolia/models/analytics/direction.rb +33 -0
- data/lib/algolia/models/analytics/error_base.rb +196 -0
- data/lib/algolia/models/analytics/get_average_click_position_response.rb +221 -0
- data/lib/algolia/models/analytics/get_click_positions_response.rb +215 -0
- data/lib/algolia/models/analytics/get_click_through_rate_response.rb +251 -0
- data/lib/algolia/models/analytics/get_conversation_rate_response.rb +251 -0
- data/lib/algolia/models/analytics/get_no_click_rate_response.rb +251 -0
- data/lib/algolia/models/analytics/get_no_results_rate_response.rb +251 -0
- data/lib/algolia/models/analytics/get_searches_count_response.rb +209 -0
- data/lib/algolia/models/analytics/get_searches_no_clicks_response.rb +197 -0
- data/lib/algolia/models/analytics/get_searches_no_results_response.rb +197 -0
- data/lib/algolia/models/analytics/get_status_response.rb +195 -0
- data/lib/algolia/models/analytics/get_top_countries_response.rb +197 -0
- data/lib/algolia/models/analytics/get_top_filter_attribute.rb +207 -0
- data/lib/algolia/models/analytics/get_top_filter_attributes_response.rb +197 -0
- data/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +231 -0
- data/lib/algolia/models/analytics/get_top_filter_for_attribute_response.rb +197 -0
- data/lib/algolia/models/analytics/get_top_filters_no_results_response.rb +197 -0
- data/lib/algolia/models/analytics/get_top_filters_no_results_value.rb +219 -0
- data/lib/algolia/models/analytics/get_top_filters_no_results_values.rb +209 -0
- data/lib/algolia/models/analytics/get_top_hits_response.rb +96 -0
- data/lib/algolia/models/analytics/get_top_searches_response.rb +96 -0
- data/lib/algolia/models/analytics/get_users_count_response.rb +209 -0
- data/lib/algolia/models/analytics/no_click_rate_event.rb +249 -0
- data/lib/algolia/models/analytics/no_results_rate_event.rb +249 -0
- data/lib/algolia/models/analytics/order_by.rb +35 -0
- data/lib/algolia/models/analytics/search_event.rb +207 -0
- data/lib/algolia/models/analytics/search_no_click_event.rb +219 -0
- data/lib/algolia/models/analytics/search_no_result_event.rb +219 -0
- data/lib/algolia/models/analytics/top_country.rb +207 -0
- data/lib/algolia/models/analytics/top_hit.rb +207 -0
- data/lib/algolia/models/analytics/top_hit_with_analytics.rb +285 -0
- data/lib/algolia/models/analytics/top_hits_response.rb +197 -0
- data/lib/algolia/models/analytics/top_hits_response_with_analytics.rb +197 -0
- data/lib/algolia/models/analytics/top_search.rb +219 -0
- data/lib/algolia/models/analytics/top_search_with_analytics.rb +309 -0
- data/lib/algolia/models/analytics/top_searches_response.rb +197 -0
- data/lib/algolia/models/analytics/top_searches_response_with_analytics.rb +197 -0
- data/lib/algolia/models/analytics/user_with_date.rb +207 -0
- data/lib/algolia/models/ingestion/action_type.rb +34 -0
- data/lib/algolia/models/ingestion/auth_algolia.rb +207 -0
- data/lib/algolia/models/ingestion/auth_algolia_partial.rb +203 -0
- data/lib/algolia/models/ingestion/auth_api_key.rb +195 -0
- data/lib/algolia/models/ingestion/auth_api_key_partial.rb +193 -0
- data/lib/algolia/models/ingestion/auth_basic.rb +206 -0
- data/lib/algolia/models/ingestion/auth_basic_partial.rb +202 -0
- data/lib/algolia/models/ingestion/auth_google_service_account.rb +208 -0
- data/lib/algolia/models/ingestion/auth_google_service_account_partial.rb +204 -0
- data/lib/algolia/models/ingestion/auth_input.rb +99 -0
- data/lib/algolia/models/ingestion/auth_input_partial.rb +99 -0
- data/lib/algolia/models/ingestion/auth_o_auth.rb +220 -0
- data/lib/algolia/models/ingestion/auth_o_auth_partial.rb +214 -0
- data/lib/algolia/models/ingestion/authentication.rb +283 -0
- data/lib/algolia/models/ingestion/authentication_create.rb +249 -0
- data/lib/algolia/models/ingestion/authentication_create_response.rb +220 -0
- data/lib/algolia/models/ingestion/authentication_search.rb +197 -0
- data/lib/algolia/models/ingestion/authentication_sort_keys.rb +36 -0
- data/lib/algolia/models/ingestion/authentication_type.rb +36 -0
- data/lib/algolia/models/ingestion/authentication_update.rb +243 -0
- data/lib/algolia/models/ingestion/authentication_update_response.rb +220 -0
- data/lib/algolia/models/ingestion/big_commerce_channel.rb +207 -0
- data/lib/algolia/models/ingestion/big_commerce_metafield.rb +207 -0
- data/lib/algolia/models/ingestion/big_query_data_type.rb +33 -0
- data/lib/algolia/models/ingestion/delete_response.rb +195 -0
- data/lib/algolia/models/ingestion/destination.rb +283 -0
- data/lib/algolia/models/ingestion/destination_create.rb +250 -0
- data/lib/algolia/models/ingestion/destination_create_response.rb +220 -0
- data/lib/algolia/models/ingestion/destination_index_name.rb +238 -0
- data/lib/algolia/models/ingestion/destination_index_prefix.rb +195 -0
- data/lib/algolia/models/ingestion/destination_input.rb +96 -0
- data/lib/algolia/models/ingestion/destination_search.rb +197 -0
- data/lib/algolia/models/ingestion/destination_sort_keys.rb +35 -0
- data/lib/algolia/models/ingestion/destination_type.rb +34 -0
- data/lib/algolia/models/ingestion/destination_update.rb +243 -0
- data/lib/algolia/models/ingestion/destination_update_response.rb +220 -0
- data/lib/algolia/models/ingestion/docker_image_type.rb +34 -0
- data/lib/algolia/models/ingestion/docker_registry.rb +33 -0
- data/lib/algolia/models/ingestion/docker_source_discover.rb +207 -0
- data/lib/algolia/models/ingestion/docker_source_streams.rb +196 -0
- data/lib/algolia/models/ingestion/error_base.rb +196 -0
- data/lib/algolia/models/ingestion/event.rb +311 -0
- data/lib/algolia/models/ingestion/event_sort_keys.rb +34 -0
- data/lib/algolia/models/ingestion/event_status.rb +37 -0
- data/lib/algolia/models/ingestion/event_type.rb +35 -0
- data/lib/algolia/models/ingestion/list_authentications_response.rb +207 -0
- data/lib/algolia/models/ingestion/list_destinations_response.rb +207 -0
- data/lib/algolia/models/ingestion/list_events_response.rb +218 -0
- data/lib/algolia/models/ingestion/list_sources_response.rb +207 -0
- data/lib/algolia/models/ingestion/list_tasks_response.rb +208 -0
- data/lib/algolia/models/ingestion/mapping_type_csv.rb +36 -0
- data/lib/algolia/models/ingestion/method_type.rb +33 -0
- data/lib/algolia/models/ingestion/on_demand_date_utils_input.rb +208 -0
- data/lib/algolia/models/ingestion/on_demand_trigger.rb +227 -0
- data/lib/algolia/models/ingestion/on_demand_trigger_input.rb +217 -0
- data/lib/algolia/models/ingestion/on_demand_trigger_type.rb +32 -0
- data/lib/algolia/models/ingestion/order_keys.rb +33 -0
- data/lib/algolia/models/ingestion/pagination.rb +227 -0
- data/lib/algolia/models/ingestion/platform.rb +33 -0
- data/lib/algolia/models/ingestion/platform_none.rb +32 -0
- data/lib/algolia/models/ingestion/platform_with_none.rb +96 -0
- data/lib/algolia/models/ingestion/record_type.rb +33 -0
- data/lib/algolia/models/ingestion/run.rb +359 -0
- data/lib/algolia/models/ingestion/run_list_response.rb +218 -0
- data/lib/algolia/models/ingestion/run_outcome.rb +34 -0
- data/lib/algolia/models/ingestion/run_progress.rb +201 -0
- data/lib/algolia/models/ingestion/run_reason_code.rb +38 -0
- data/lib/algolia/models/ingestion/run_response.rb +208 -0
- data/lib/algolia/models/ingestion/run_sort_keys.rb +34 -0
- data/lib/algolia/models/ingestion/run_status.rb +36 -0
- data/lib/algolia/models/ingestion/run_type.rb +34 -0
- data/lib/algolia/models/ingestion/schedule_date_utils_input.rb +214 -0
- data/lib/algolia/models/ingestion/schedule_trigger.rb +251 -0
- data/lib/algolia/models/ingestion/schedule_trigger_input.rb +229 -0
- data/lib/algolia/models/ingestion/schedule_trigger_type.rb +32 -0
- data/lib/algolia/models/ingestion/source.rb +282 -0
- data/lib/algolia/models/ingestion/source_big_commerce.rb +235 -0
- data/lib/algolia/models/ingestion/source_big_query.rb +278 -0
- data/lib/algolia/models/ingestion/source_commercetools.rb +238 -0
- data/lib/algolia/models/ingestion/source_create.rb +248 -0
- data/lib/algolia/models/ingestion/source_create_response.rb +218 -0
- data/lib/algolia/models/ingestion/source_csv.rb +276 -0
- data/lib/algolia/models/ingestion/source_docker.rb +261 -0
- data/lib/algolia/models/ingestion/source_input.rb +100 -0
- data/lib/algolia/models/ingestion/source_json.rb +236 -0
- data/lib/algolia/models/ingestion/source_search.rb +196 -0
- data/lib/algolia/models/ingestion/source_sort_keys.rb +35 -0
- data/lib/algolia/models/ingestion/source_type.rb +37 -0
- data/lib/algolia/models/ingestion/source_update.rb +211 -0
- data/lib/algolia/models/ingestion/source_update_commercetools.rb +207 -0
- data/lib/algolia/models/ingestion/source_update_docker.rb +246 -0
- data/lib/algolia/models/ingestion/source_update_input.rb +99 -0
- data/lib/algolia/models/ingestion/source_update_response.rb +218 -0
- data/lib/algolia/models/ingestion/subscription_trigger.rb +217 -0
- data/lib/algolia/models/ingestion/subscription_trigger_type.rb +32 -0
- data/lib/algolia/models/ingestion/task.rb +334 -0
- data/lib/algolia/models/ingestion/task_create.rb +299 -0
- data/lib/algolia/models/ingestion/task_create_response.rb +208 -0
- data/lib/algolia/models/ingestion/task_create_trigger.rb +97 -0
- data/lib/algolia/models/ingestion/task_input.rb +96 -0
- data/lib/algolia/models/ingestion/task_search.rb +196 -0
- data/lib/algolia/models/ingestion/task_sort_keys.rb +36 -0
- data/lib/algolia/models/ingestion/task_update.rb +250 -0
- data/lib/algolia/models/ingestion/task_update_response.rb +208 -0
- data/lib/algolia/models/ingestion/trigger.rb +97 -0
- data/lib/algolia/models/ingestion/trigger_type.rb +34 -0
- data/lib/algolia/models/ingestion/trigger_update_input.rb +196 -0
- data/lib/algolia/models/ingestion/window.rb +208 -0
- data/lib/algolia/models/insights/add_to_cart_event.rb +32 -0
- data/lib/algolia/models/insights/added_to_cart_object_ids.rb +384 -0
- data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +419 -0
- data/lib/algolia/models/insights/click_event.rb +32 -0
- data/lib/algolia/models/insights/clicked_filters.rb +351 -0
- data/lib/algolia/models/insights/clicked_object_ids.rb +341 -0
- data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +418 -0
- data/lib/algolia/models/insights/conversion_event.rb +32 -0
- data/lib/algolia/models/insights/converted_filters.rb +350 -0
- data/lib/algolia/models/insights/converted_object_ids.rb +351 -0
- data/lib/algolia/models/insights/converted_object_ids_after_search.rb +386 -0
- data/lib/algolia/models/insights/discount.rb +97 -0
- data/lib/algolia/models/insights/error_base.rb +196 -0
- data/lib/algolia/models/insights/events_items.rb +106 -0
- data/lib/algolia/models/insights/events_response.rb +204 -0
- data/lib/algolia/models/insights/insights_events.rb +215 -0
- data/lib/algolia/models/insights/object_data.rb +211 -0
- data/lib/algolia/models/insights/object_data_after_search.rb +221 -0
- data/lib/algolia/models/insights/price.rb +97 -0
- data/lib/algolia/models/insights/purchase_event.rb +32 -0
- data/lib/algolia/models/insights/purchased_object_ids.rb +384 -0
- data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +419 -0
- data/lib/algolia/models/insights/view_event.rb +32 -0
- data/lib/algolia/models/insights/viewed_filters.rb +351 -0
- data/lib/algolia/models/insights/viewed_object_ids.rb +351 -0
- data/lib/algolia/models/monitoring/error_base.rb +196 -0
- data/lib/algolia/models/monitoring/get_inventory403_response.rb +192 -0
- data/lib/algolia/models/monitoring/incident.rb +225 -0
- data/lib/algolia/models/monitoring/incidents_inner.rb +202 -0
- data/lib/algolia/models/monitoring/incidents_response.rb +194 -0
- data/lib/algolia/models/monitoring/indexing_time_response.rb +192 -0
- data/lib/algolia/models/monitoring/indexing_time_response_metrics.rb +194 -0
- data/lib/algolia/models/monitoring/infrastructure_response.rb +192 -0
- data/lib/algolia/models/monitoring/infrastructure_response_metrics.rb +243 -0
- data/lib/algolia/models/monitoring/inventory_response.rb +194 -0
- data/lib/algolia/models/monitoring/latency_response.rb +192 -0
- data/lib/algolia/models/monitoring/latency_response_metrics.rb +194 -0
- data/lib/algolia/models/monitoring/metric.rb +37 -0
- data/lib/algolia/models/monitoring/period.rb +36 -0
- data/lib/algolia/models/monitoring/probes_metric.rb +203 -0
- data/lib/algolia/models/monitoring/region.rb +46 -0
- data/lib/algolia/models/monitoring/server.rb +272 -0
- data/lib/algolia/models/monitoring/server_status.rb +32 -0
- data/lib/algolia/models/monitoring/status.rb +35 -0
- data/lib/algolia/models/monitoring/status_response.rb +194 -0
- data/lib/algolia/models/monitoring/time_inner.rb +203 -0
- data/lib/algolia/models/monitoring/type.rb +32 -0
- data/lib/algolia/models/personalization/delete_user_profile_response.rb +207 -0
- data/lib/algolia/models/personalization/error_base.rb +196 -0
- data/lib/algolia/models/personalization/event_scoring.rb +219 -0
- data/lib/algolia/models/personalization/facet_scoring.rb +207 -0
- data/lib/algolia/models/personalization/get_user_token_response.rb +219 -0
- data/lib/algolia/models/personalization/personalization_strategy_params.rb +223 -0
- data/lib/algolia/models/personalization/set_personalization_strategy_response.rb +195 -0
- data/lib/algolia/models/query-suggestions/base_query_suggestions_configuration_response.rb +223 -0
- data/lib/algolia/models/query-suggestions/base_query_suggestions_configuration_with_index.rb +195 -0
- data/lib/algolia/models/query-suggestions/base_response.rb +203 -0
- data/lib/algolia/models/query-suggestions/error_base.rb +196 -0
- data/lib/algolia/models/query-suggestions/facet.rb +204 -0
- data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +233 -0
- data/lib/algolia/models/query-suggestions/get_log_file200_response.rb +244 -0
- data/lib/algolia/models/query-suggestions/languages.rb +97 -0
- data/lib/algolia/models/query-suggestions/log_level.rb +34 -0
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration.rb +255 -0
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +315 -0
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +275 -0
- data/lib/algolia/models/query-suggestions/source_index.rb +305 -0
- data/lib/algolia/models/recommend/advanced_syntax_features.rb +33 -0
- data/lib/algolia/models/recommend/alternatives_as_exact.rb +34 -0
- data/lib/algolia/models/recommend/anchoring.rb +35 -0
- data/lib/algolia/models/recommend/around_precision.rb +97 -0
- data/lib/algolia/models/recommend/around_precision_from_value_inner.rb +201 -0
- data/lib/algolia/models/recommend/around_radius.rb +97 -0
- data/lib/algolia/models/recommend/around_radius_all.rb +32 -0
- data/lib/algolia/models/recommend/automatic_facet_filter.rb +216 -0
- data/lib/algolia/models/recommend/automatic_facet_filters.rb +97 -0
- data/lib/algolia/models/recommend/base_recommend_request.rb +233 -0
- data/lib/algolia/models/recommend/base_recommendations_query.rb +246 -0
- data/lib/algolia/models/recommend/base_recommended_for_you_query.rb +234 -0
- data/lib/algolia/models/recommend/base_recommended_for_you_query_parameters.rb +195 -0
- data/lib/algolia/models/recommend/base_search_params.rb +564 -0
- data/lib/algolia/models/recommend/base_search_params_without_query.rb +546 -0
- data/lib/algolia/models/recommend/base_search_response.rb +517 -0
- data/lib/algolia/models/recommend/base_trending_facets_query.rb +226 -0
- data/lib/algolia/models/recommend/base_trending_items_query.rb +252 -0
- data/lib/algolia/models/recommend/condition.rb +244 -0
- data/lib/algolia/models/recommend/consequence.rb +239 -0
- data/lib/algolia/models/recommend/consequence_hide.rb +196 -0
- data/lib/algolia/models/recommend/consequence_params.rb +1121 -0
- data/lib/algolia/models/recommend/consequence_query.rb +97 -0
- data/lib/algolia/models/recommend/consequence_query_object.rb +207 -0
- data/lib/algolia/models/recommend/deleted_at_response.rb +208 -0
- data/lib/algolia/models/recommend/distinct.rb +97 -0
- data/lib/algolia/models/recommend/edit.rb +234 -0
- data/lib/algolia/models/recommend/edit_type.rb +33 -0
- data/lib/algolia/models/recommend/error_base.rb +196 -0
- data/lib/algolia/models/recommend/exact_on_single_word_query.rb +34 -0
- data/lib/algolia/models/recommend/exhaustive.rb +234 -0
- data/lib/algolia/models/recommend/facet_filters.rb +97 -0
- data/lib/algolia/models/recommend/facet_ordering.rb +205 -0
- data/lib/algolia/models/recommend/facets.rb +196 -0
- data/lib/algolia/models/recommend/facets_stats.rb +223 -0
- data/lib/algolia/models/recommend/get_recommend_task_response.rb +216 -0
- data/lib/algolia/models/recommend/get_recommendations_params.rb +198 -0
- data/lib/algolia/models/recommend/get_recommendations_response.rb +194 -0
- data/lib/algolia/models/recommend/highlight_result.rb +96 -0
- data/lib/algolia/models/recommend/highlight_result_option.rb +253 -0
- data/lib/algolia/models/recommend/ignore_plurals.rb +97 -0
- data/lib/algolia/models/recommend/index_settings_as_search_params.rb +723 -0
- data/lib/algolia/models/recommend/match_level.rb +34 -0
- data/lib/algolia/models/recommend/matched_geo_location.rb +213 -0
- data/lib/algolia/models/recommend/mixed_search_filters.rb +96 -0
- data/lib/algolia/models/recommend/mode.rb +33 -0
- data/lib/algolia/models/recommend/numeric_filters.rb +97 -0
- data/lib/algolia/models/recommend/optional_filters.rb +97 -0
- data/lib/algolia/models/recommend/params.rb +220 -0
- data/lib/algolia/models/recommend/personalization.rb +213 -0
- data/lib/algolia/models/recommend/promote.rb +96 -0
- data/lib/algolia/models/recommend/promote_object_id.rb +208 -0
- data/lib/algolia/models/recommend/promote_object_ids.rb +210 -0
- data/lib/algolia/models/recommend/query_type.rb +34 -0
- data/lib/algolia/models/recommend/ranking_info.rb +328 -0
- data/lib/algolia/models/recommend/re_ranking_apply_filter.rb +97 -0
- data/lib/algolia/models/recommend/recommend_hit.rb +271 -0
- data/lib/algolia/models/recommend/recommend_models.rb +35 -0
- data/lib/algolia/models/recommend/recommendation_models.rb +33 -0
- data/lib/algolia/models/recommend/recommendations_hit.rb +96 -0
- data/lib/algolia/models/recommend/recommendations_hits.rb +216 -0
- data/lib/algolia/models/recommend/recommendations_query.rb +304 -0
- data/lib/algolia/models/recommend/recommendations_request.rb +98 -0
- data/lib/algolia/models/recommend/recommendations_results.rb +553 -0
- data/lib/algolia/models/recommend/recommended_for_you_model.rb +32 -0
- data/lib/algolia/models/recommend/recommended_for_you_query.rb +292 -0
- data/lib/algolia/models/recommend/recommended_for_you_query_parameters.rb +1105 -0
- data/lib/algolia/models/recommend/redirect.rb +195 -0
- data/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +242 -0
- data/lib/algolia/models/recommend/redirect_rule_index_metadata_data.rb +195 -0
- data/lib/algolia/models/recommend/remove_stop_words.rb +97 -0
- data/lib/algolia/models/recommend/remove_words_if_no_results.rb +35 -0
- data/lib/algolia/models/recommend/rendering_content.rb +193 -0
- data/lib/algolia/models/recommend/rule_response.rb +246 -0
- data/lib/algolia/models/recommend/rule_response_metadata.rb +193 -0
- data/lib/algolia/models/recommend/search_params_object.rb +1103 -0
- data/lib/algolia/models/recommend/search_params_query.rb +193 -0
- data/lib/algolia/models/recommend/search_recommend_rules_params.rb +268 -0
- data/lib/algolia/models/recommend/search_recommend_rules_response.rb +233 -0
- data/lib/algolia/models/recommend/semantic_search.rb +198 -0
- data/lib/algolia/models/recommend/snippet_result.rb +96 -0
- data/lib/algolia/models/recommend/snippet_result_option.rb +229 -0
- data/lib/algolia/models/recommend/sort_remaining_by.rb +34 -0
- data/lib/algolia/models/recommend/tag_filters.rb +97 -0
- data/lib/algolia/models/recommend/task_status.rb +33 -0
- data/lib/algolia/models/recommend/trending_facet_hit.rb +238 -0
- data/lib/algolia/models/recommend/trending_facets_model.rb +32 -0
- data/lib/algolia/models/recommend/trending_facets_query.rb +284 -0
- data/lib/algolia/models/recommend/trending_items_model.rb +32 -0
- data/lib/algolia/models/recommend/trending_items_query.rb +310 -0
- data/lib/algolia/models/recommend/typo_tolerance.rb +97 -0
- data/lib/algolia/models/recommend/typo_tolerance_enum.rb +33 -0
- data/lib/algolia/models/recommend/value.rb +226 -0
- data/lib/algolia/models/search/acl.rb +47 -0
- data/lib/algolia/models/search/action.rb +38 -0
- data/lib/algolia/models/search/add_api_key_response.rb +207 -0
- data/lib/algolia/models/search/advanced_syntax_features.rb +33 -0
- data/lib/algolia/models/search/alternatives_as_exact.rb +34 -0
- data/lib/algolia/models/search/anchoring.rb +35 -0
- data/lib/algolia/models/search/api_key.rb +272 -0
- data/lib/algolia/models/search/around_precision.rb +97 -0
- data/lib/algolia/models/search/around_precision_from_value_inner.rb +201 -0
- data/lib/algolia/models/search/around_radius.rb +97 -0
- data/lib/algolia/models/search/around_radius_all.rb +32 -0
- data/lib/algolia/models/search/assign_user_id_params.rb +196 -0
- data/lib/algolia/models/search/attribute_to_update.rb +96 -0
- data/lib/algolia/models/search/automatic_facet_filter.rb +216 -0
- data/lib/algolia/models/search/automatic_facet_filters.rb +97 -0
- data/lib/algolia/models/search/base_get_api_key_response.rb +205 -0
- data/lib/algolia/models/search/base_index_settings.rb +366 -0
- data/lib/algolia/models/search/base_search_params.rb +564 -0
- data/lib/algolia/models/search/base_search_params_without_query.rb +546 -0
- data/lib/algolia/models/search/base_search_response.rb +517 -0
- data/lib/algolia/models/search/batch_assign_user_ids_params.rb +210 -0
- data/lib/algolia/models/search/batch_dictionary_entries_params.rb +208 -0
- data/lib/algolia/models/search/batch_dictionary_entries_request.rb +227 -0
- data/lib/algolia/models/search/batch_params.rb +197 -0
- data/lib/algolia/models/search/batch_request.rb +228 -0
- data/lib/algolia/models/search/batch_response.rb +209 -0
- data/lib/algolia/models/search/batch_write_params.rb +197 -0
- data/lib/algolia/models/search/browse_params.rb +96 -0
- data/lib/algolia/models/search/browse_params_object.rb +1113 -0
- data/lib/algolia/models/search/browse_response.rb +568 -0
- data/lib/algolia/models/search/built_in_operation.rb +229 -0
- data/lib/algolia/models/search/built_in_operation_type.rb +38 -0
- data/lib/algolia/models/search/condition.rb +244 -0
- data/lib/algolia/models/search/consequence.rb +239 -0
- data/lib/algolia/models/search/consequence_hide.rb +196 -0
- data/lib/algolia/models/search/consequence_params.rb +1121 -0
- data/lib/algolia/models/search/consequence_query.rb +97 -0
- data/lib/algolia/models/search/consequence_query_object.rb +207 -0
- data/lib/algolia/models/search/created_at_response.rb +196 -0
- data/lib/algolia/models/search/cursor.rb +193 -0
- data/lib/algolia/models/search/delete_api_key_response.rb +195 -0
- data/lib/algolia/models/search/delete_by_params.rb +263 -0
- data/lib/algolia/models/search/delete_source_response.rb +195 -0
- data/lib/algolia/models/search/deleted_at_response.rb +208 -0
- data/lib/algolia/models/search/dictionary_action.rb +33 -0
- data/lib/algolia/models/search/dictionary_entry.rb +276 -0
- data/lib/algolia/models/search/dictionary_entry_state.rb +33 -0
- data/lib/algolia/models/search/dictionary_language.rb +194 -0
- data/lib/algolia/models/search/dictionary_settings_params.rb +195 -0
- data/lib/algolia/models/search/dictionary_type.rb +34 -0
- data/lib/algolia/models/search/distinct.rb +97 -0
- data/lib/algolia/models/search/edit.rb +234 -0
- data/lib/algolia/models/search/edit_type.rb +33 -0
- data/lib/algolia/models/search/error_base.rb +196 -0
- data/lib/algolia/models/search/exact_on_single_word_query.rb +34 -0
- data/lib/algolia/models/search/exhaustive.rb +234 -0
- data/lib/algolia/models/search/facet_filters.rb +97 -0
- data/lib/algolia/models/search/facet_hits.rb +219 -0
- data/lib/algolia/models/search/facet_ordering.rb +205 -0
- data/lib/algolia/models/search/facets.rb +196 -0
- data/lib/algolia/models/search/facets_stats.rb +223 -0
- data/lib/algolia/models/search/fetched_index.rb +313 -0
- data/lib/algolia/models/search/get_api_key_response.rb +301 -0
- data/lib/algolia/models/search/get_dictionary_settings_response.rb +194 -0
- data/lib/algolia/models/search/get_logs_response.rb +196 -0
- data/lib/algolia/models/search/get_objects_params.rb +197 -0
- data/lib/algolia/models/search/get_objects_request.rb +220 -0
- data/lib/algolia/models/search/get_objects_response.rb +197 -0
- data/lib/algolia/models/search/get_task_response.rb +216 -0
- data/lib/algolia/models/search/get_top_user_ids_response.rb +198 -0
- data/lib/algolia/models/search/has_pending_mappings_response.rb +207 -0
- data/lib/algolia/models/search/highlight_result.rb +96 -0
- data/lib/algolia/models/search/highlight_result_option.rb +253 -0
- data/lib/algolia/models/search/hit.rb +241 -0
- data/lib/algolia/models/search/ignore_plurals.rb +97 -0
- data/lib/algolia/models/search/index_settings.rb +912 -0
- data/lib/algolia/models/search/index_settings_as_search_params.rb +723 -0
- data/lib/algolia/models/search/languages.rb +221 -0
- data/lib/algolia/models/search/list_api_keys_response.rb +197 -0
- data/lib/algolia/models/search/list_clusters_response.rb +198 -0
- data/lib/algolia/models/search/list_indices_response.rb +207 -0
- data/lib/algolia/models/search/list_user_ids_response.rb +198 -0
- data/lib/algolia/models/search/log.rb +358 -0
- data/lib/algolia/models/search/log_query.rb +213 -0
- data/lib/algolia/models/search/log_type.rb +35 -0
- data/lib/algolia/models/search/match_level.rb +34 -0
- data/lib/algolia/models/search/matched_geo_location.rb +213 -0
- data/lib/algolia/models/search/mixed_search_filters.rb +96 -0
- data/lib/algolia/models/search/mode.rb +33 -0
- data/lib/algolia/models/search/multiple_batch_request.rb +240 -0
- data/lib/algolia/models/search/multiple_batch_response.rb +211 -0
- data/lib/algolia/models/search/numeric_filters.rb +97 -0
- data/lib/algolia/models/search/operation_index_params.rb +240 -0
- data/lib/algolia/models/search/operation_type.rb +33 -0
- data/lib/algolia/models/search/optional_filters.rb +97 -0
- data/lib/algolia/models/search/params.rb +220 -0
- data/lib/algolia/models/search/personalization.rb +213 -0
- data/lib/algolia/models/search/promote.rb +96 -0
- data/lib/algolia/models/search/promote_object_id.rb +208 -0
- data/lib/algolia/models/search/promote_object_ids.rb +210 -0
- data/lib/algolia/models/search/query_type.rb +34 -0
- data/lib/algolia/models/search/ranking_info.rb +328 -0
- data/lib/algolia/models/search/re_ranking_apply_filter.rb +97 -0
- data/lib/algolia/models/search/redirect.rb +195 -0
- data/lib/algolia/models/search/redirect_rule_index_metadata.rb +242 -0
- data/lib/algolia/models/search/redirect_rule_index_metadata_data.rb +195 -0
- data/lib/algolia/models/search/remove_stop_words.rb +97 -0
- data/lib/algolia/models/search/remove_user_id_response.rb +195 -0
- data/lib/algolia/models/search/remove_words_if_no_results.rb +35 -0
- data/lib/algolia/models/search/rendering_content.rb +193 -0
- data/lib/algolia/models/search/replace_source_response.rb +195 -0
- data/lib/algolia/models/search/rule.rb +249 -0
- data/lib/algolia/models/search/save_object_response.rb +217 -0
- data/lib/algolia/models/search/save_synonym_response.rb +219 -0
- data/lib/algolia/models/search/scope_type.rb +34 -0
- data/lib/algolia/models/search/search_dictionary_entries_params.rb +244 -0
- data/lib/algolia/models/search/search_for_facet_values_request.rb +227 -0
- data/lib/algolia/models/search/search_for_facet_values_response.rb +218 -0
- data/lib/algolia/models/search/search_for_facets.rb +1158 -0
- data/lib/algolia/models/search/search_for_facets_options.rb +274 -0
- data/lib/algolia/models/search/search_for_hits.rb +1134 -0
- data/lib/algolia/models/search/search_for_hits_options.rb +226 -0
- data/lib/algolia/models/search/search_hits.rb +223 -0
- data/lib/algolia/models/search/search_method_params.rb +227 -0
- data/lib/algolia/models/search/search_params.rb +96 -0
- data/lib/algolia/models/search/search_params_object.rb +1103 -0
- data/lib/algolia/models/search/search_params_query.rb +193 -0
- data/lib/algolia/models/search/search_params_string.rb +193 -0
- data/lib/algolia/models/search/search_query.rb +96 -0
- data/lib/algolia/models/search/search_response.rb +560 -0
- data/lib/algolia/models/search/search_responses.rb +196 -0
- data/lib/algolia/models/search/search_result.rb +96 -0
- data/lib/algolia/models/search/search_rules_params.rb +311 -0
- data/lib/algolia/models/search/search_rules_response.rb +233 -0
- data/lib/algolia/models/search/search_strategy.rb +33 -0
- data/lib/algolia/models/search/search_synonyms_params.rb +193 -0
- data/lib/algolia/models/search/search_synonyms_response.rb +212 -0
- data/lib/algolia/models/search/search_type_default.rb +32 -0
- data/lib/algolia/models/search/search_type_facet.rb +32 -0
- data/lib/algolia/models/search/search_user_ids_params.rb +244 -0
- data/lib/algolia/models/search/search_user_ids_response.rb +264 -0
- data/lib/algolia/models/search/semantic_search.rb +198 -0
- data/lib/algolia/models/search/snippet_result.rb +96 -0
- data/lib/algolia/models/search/snippet_result_option.rb +229 -0
- data/lib/algolia/models/search/sort_remaining_by.rb +34 -0
- data/lib/algolia/models/search/source.rb +206 -0
- data/lib/algolia/models/search/standard_entries.rb +224 -0
- data/lib/algolia/models/search/synonym_hit.rb +295 -0
- data/lib/algolia/models/search/synonym_type.rb +36 -0
- data/lib/algolia/models/search/tag_filters.rb +97 -0
- data/lib/algolia/models/search/task_status.rb +33 -0
- data/lib/algolia/models/search/time_range.rb +207 -0
- data/lib/algolia/models/search/typo_tolerance.rb +97 -0
- data/lib/algolia/models/search/typo_tolerance_enum.rb +33 -0
- data/lib/algolia/models/search/update_api_key_response.rb +207 -0
- data/lib/algolia/models/search/updated_at_response.rb +208 -0
- data/lib/algolia/models/search/updated_at_with_object_id_response.rb +214 -0
- data/lib/algolia/models/search/updated_rule_response.rb +219 -0
- data/lib/algolia/models/search/user_highlight_result.rb +205 -0
- data/lib/algolia/models/search/user_hit.rb +269 -0
- data/lib/algolia/models/search/user_id.rb +247 -0
- data/lib/algolia/models/search/value.rb +226 -0
- data/lib/algolia/transport/echo_requester.rb +10 -0
- data/lib/algolia/{http → transport/http}/http_requester.rb +24 -19
- data/lib/algolia/{http → transport/http}/response.rb +11 -1
- data/lib/algolia/transport/request_options.rb +19 -31
- data/lib/algolia/transport/retry_strategy.rb +5 -8
- data/lib/algolia/transport/stateful_host.rb +1 -2
- data/lib/algolia/transport/transport.rb +33 -73
- data/lib/algolia/user_agent.rb +4 -14
- data/lib/algolia/version.rb +3 -1
- data/lib/algolia.rb +23 -40
- metadata +522 -217
- data/.circleci/config.yml +0 -155
- data/.dockerignore +0 -38
- data/.github/ISSUE_TEMPLATE.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -22
- data/.gitignore +0 -40
- data/.rubocop.yml +0 -189
- data/.rubocop_todo.yml +0 -14
- data/CODE_OF_CONDUCT.md +0 -74
- data/CONTRIBUTING.MD +0 -184
- data/DOCKER_README.MD +0 -89
- data/Dockerfile +0 -7
- data/LICENSE +0 -21
- data/SECURITY.md +0 -3
- data/Steepfile +0 -6
- data/bin/console +0 -21
- data/bin/setup +0 -8
- data/lib/algolia/account_client.rb +0 -65
- data/lib/algolia/analytics_client.rb +0 -105
- data/lib/algolia/config/analytics_config.rb +0 -20
- data/lib/algolia/config/base_config.rb +0 -43
- data/lib/algolia/config/insights_config.rb +0 -20
- data/lib/algolia/config/personalization_config.rb +0 -20
- data/lib/algolia/config/recommend_config.rb +0 -6
- data/lib/algolia/config/recommendation_config.rb +0 -7
- data/lib/algolia/config/search_config.rb +0 -40
- data/lib/algolia/defaults.rb +0 -35
- data/lib/algolia/helpers.rb +0 -134
- data/lib/algolia/insights_client.rb +0 -238
- data/lib/algolia/iterators/base_iterator.rb +0 -19
- data/lib/algolia/iterators/object_iterator.rb +0 -28
- data/lib/algolia/iterators/paginator_iterator.rb +0 -46
- data/lib/algolia/iterators/rule_iterator.rb +0 -9
- data/lib/algolia/iterators/synonym_iterator.rb +0 -9
- data/lib/algolia/personalization_client.rb +0 -60
- data/lib/algolia/recommend_client.rb +0 -134
- data/lib/algolia/recommendation_client.rb +0 -7
- data/lib/algolia/responses/add_api_key_response.rb +0 -38
- data/lib/algolia/responses/base_response.rb +0 -9
- data/lib/algolia/responses/delete_api_key_response.rb +0 -40
- data/lib/algolia/responses/dictionary_response.rb +0 -33
- data/lib/algolia/responses/indexing_response.rb +0 -28
- data/lib/algolia/responses/multiple_batch_indexing_response.rb +0 -29
- data/lib/algolia/responses/multiple_response.rb +0 -45
- data/lib/algolia/responses/restore_api_key_response.rb +0 -36
- data/lib/algolia/responses/update_api_key_response.rb +0 -39
- data/lib/algolia/search_client.rb +0 -791
- data/lib/algolia/search_index.rb +0 -1059
- data/renovate.json +0 -5
- data/sig/config/algolia_config.rbs +0 -24
- data/sig/config/analytics_config.rbs +0 -11
- data/sig/config/insights_config.rbs +0 -11
- data/sig/config/recommendation_config.rbs +0 -11
- data/sig/config/search_config.rbs +0 -11
- data/sig/enums/call_type.rbs +0 -5
- data/sig/helpers.rbs +0 -12
- data/sig/http/http_requester.rbs +0 -17
- data/sig/http/response.rbs +0 -14
- data/sig/interfaces/_connection.rbs +0 -16
- data/sig/iterators/base_iterator.rbs +0 -15
- data/sig/iterators/object_iterator.rbs +0 -6
- data/sig/iterators/paginator_iterator.rbs +0 -8
- data/sig/iterators/rule_iterator.rbs +0 -5
- data/sig/iterators/synonym_iterator.rbs +0 -5
- data/sig/transport/request_options.rbs +0 -33
- data/sig/transport/stateful_host.rbs +0 -21
- data/test/algolia/integration/account_client_test.rb +0 -47
- data/test/algolia/integration/analytics_client_test.rb +0 -117
- data/test/algolia/integration/base_test.rb +0 -9
- data/test/algolia/integration/insights_client_test.rb +0 -80
- data/test/algolia/integration/mocks/mock_requester.rb +0 -47
- data/test/algolia/integration/personalization_client_test.rb +0 -30
- data/test/algolia/integration/recommend_client_test.rb +0 -70
- data/test/algolia/integration/recommendation_client_test.rb +0 -30
- data/test/algolia/integration/search_client_test.rb +0 -465
- data/test/algolia/integration/search_index_test.rb +0 -729
- data/test/algolia/unit/algolia_config_test.rb +0 -16
- data/test/algolia/unit/helpers_test.rb +0 -92
- data/test/algolia/unit/http_requester_test.rb +0 -27
- data/test/algolia/unit/retry_strategy_test.rb +0 -139
- data/test/algolia/unit/user_agent_test.rb +0 -16
- data/test/test_helper.rb +0 -121
- data/upgrade_guide.md +0 -603
- /data/lib/algolia/{enums → transport}/call_type.rb +0 -0
- /data/lib/algolia/{enums → transport}/retry_outcome_type.rb +0 -0
data/lib/algolia/search_index.rb
DELETED
@@ -1,1059 +0,0 @@
|
|
1
|
-
module Algolia
|
2
|
-
module Search
|
3
|
-
# Class Index
|
4
|
-
class Index
|
5
|
-
include CallType
|
6
|
-
include Helpers
|
7
|
-
|
8
|
-
attr_reader :name, :transporter, :config, :logger
|
9
|
-
|
10
|
-
# Initialize an index
|
11
|
-
#
|
12
|
-
# @param name [String] name of the index
|
13
|
-
# @param transporter [Object] transport object used for the connection
|
14
|
-
# @param config [Config] a Config object which contains your APP_ID and API_KEY
|
15
|
-
# @param logger [LoggerHelper] an optional LoggerHelper object to use
|
16
|
-
#
|
17
|
-
def initialize(name, transporter, config, logger = nil)
|
18
|
-
@name = name
|
19
|
-
@transporter = transporter
|
20
|
-
@config = config
|
21
|
-
@logger = logger || LoggerHelper.create
|
22
|
-
end
|
23
|
-
|
24
|
-
# # # # # # # # # # # # # # # # # # # # #
|
25
|
-
# MISC
|
26
|
-
# # # # # # # # # # # # # # # # # # # # #
|
27
|
-
|
28
|
-
# Wait the publication of a task on the server.
|
29
|
-
# All server task are asynchronous and you can check with this method that the task is published.
|
30
|
-
#
|
31
|
-
# @param task_id the id of the task returned by server
|
32
|
-
# @param time_before_retry the time in milliseconds before retry (default = 100ms)
|
33
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
34
|
-
#
|
35
|
-
def wait_task(task_id, time_before_retry = Defaults::WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, opts = {})
|
36
|
-
loop do
|
37
|
-
status = get_task_status(task_id, opts)
|
38
|
-
if status == 'published'
|
39
|
-
return
|
40
|
-
end
|
41
|
-
sleep(time_before_retry.to_f / 1000)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Check the status of a task on the server.
|
46
|
-
# All server task are asynchronous and you can check the status of a task with this method.
|
47
|
-
#
|
48
|
-
# @param task_id [Integer] the id of the task returned by server
|
49
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
50
|
-
#
|
51
|
-
def get_task_status(task_id, opts = {})
|
52
|
-
res = @transporter.read(:GET, path_encode('/1/indexes/%s/task/%s', @name, task_id), {}, opts)
|
53
|
-
get_option(res, 'status')
|
54
|
-
end
|
55
|
-
|
56
|
-
# Delete the index content
|
57
|
-
#
|
58
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
59
|
-
#
|
60
|
-
def clear_objects(opts = {})
|
61
|
-
response = @transporter.write(:POST, path_encode('/1/indexes/%s/clear', @name), {}, opts)
|
62
|
-
|
63
|
-
IndexingResponse.new(self, response)
|
64
|
-
end
|
65
|
-
|
66
|
-
# Delete the index content and wait for operation to complete
|
67
|
-
#
|
68
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
69
|
-
#
|
70
|
-
def clear_objects!(opts = {})
|
71
|
-
response = clear_objects(opts)
|
72
|
-
response.wait(opts)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Delete an existing index
|
76
|
-
#
|
77
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
78
|
-
#
|
79
|
-
def delete(opts = {})
|
80
|
-
response = @transporter.write(:DELETE, path_encode('/1/indexes/%s', @name), opts)
|
81
|
-
|
82
|
-
IndexingResponse.new(self, response)
|
83
|
-
end
|
84
|
-
|
85
|
-
# Delete an existing index and wait for operation to complete
|
86
|
-
#
|
87
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
88
|
-
#
|
89
|
-
def delete!(opts = {})
|
90
|
-
response = delete(opts)
|
91
|
-
response.wait(opts)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Find object by the given condition.
|
95
|
-
#
|
96
|
-
# Options can be passed in request_options body:
|
97
|
-
# - query (string): pass a query
|
98
|
-
# - paginate (bool): choose if you want to iterate through all the
|
99
|
-
# documents (true) or only the first page (false). Default is true.
|
100
|
-
# The function takes a block to filter the results from search query
|
101
|
-
# Usage example:
|
102
|
-
# index.find_object({'query' => '', 'paginate' => true}) {|obj| obj.key?('company') and obj['company'] == 'Apple'}
|
103
|
-
#
|
104
|
-
# @param callback [Lambda] contains extra parameters to send with your query
|
105
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
106
|
-
#
|
107
|
-
# @return [Hash|AlgoliaHttpError] the matching object and its position in the result set
|
108
|
-
#
|
109
|
-
def find_object(callback, opts = {})
|
110
|
-
request_options = symbolize_hash(opts)
|
111
|
-
paginate = true
|
112
|
-
page = 0
|
113
|
-
|
114
|
-
query = request_options.delete(:query) || ''
|
115
|
-
paginate = request_options.delete(:paginate) if request_options.has_key?(:paginate)
|
116
|
-
|
117
|
-
has_next_page = true
|
118
|
-
while has_next_page
|
119
|
-
request_options[:page] = page
|
120
|
-
res = symbolize_hash(search(query, request_options))
|
121
|
-
|
122
|
-
res[:hits].each_with_index do |hit, i|
|
123
|
-
if callback.call(hit)
|
124
|
-
return {
|
125
|
-
object: hit,
|
126
|
-
position: i,
|
127
|
-
page: page
|
128
|
-
}
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
has_next_page = page + 1 < res[:nbPages]
|
133
|
-
raise AlgoliaHttpError.new(404, 'Object not found') unless paginate && has_next_page
|
134
|
-
|
135
|
-
page += 1
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
# Retrieve the given object position in a set of results.
|
140
|
-
#
|
141
|
-
# @param [Array] objects the result set to browse
|
142
|
-
# @param [String] object_id the object to look for
|
143
|
-
#
|
144
|
-
# @return [Integer] position of the object, or -1 if it's not in the array
|
145
|
-
#
|
146
|
-
def self.get_object_position(objects, object_id)
|
147
|
-
hits = get_option(objects, 'hits')
|
148
|
-
hits.find_index { |hit| get_option(hit, 'objectID') == object_id } || -1
|
149
|
-
end
|
150
|
-
|
151
|
-
# Copy the current index to the given destination name
|
152
|
-
#
|
153
|
-
# @param name [String] destination index name
|
154
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
155
|
-
#
|
156
|
-
# @return [IndexingResponse]
|
157
|
-
#
|
158
|
-
def copy_to(name, opts = {})
|
159
|
-
response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @name), { operation: 'copy', destination: name }, opts)
|
160
|
-
|
161
|
-
IndexingResponse.new(self, response)
|
162
|
-
end
|
163
|
-
|
164
|
-
# Move the current index to the given destination name
|
165
|
-
#
|
166
|
-
# @param name [String] destination index name
|
167
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
168
|
-
#
|
169
|
-
# @return [IndexingResponse]
|
170
|
-
#
|
171
|
-
def move_to(name, opts = {})
|
172
|
-
response = @transporter.write(:POST, path_encode('/1/indexes/%s/operation', @name), { operation: 'move', destination: name }, opts)
|
173
|
-
|
174
|
-
IndexingResponse.new(self, response)
|
175
|
-
end
|
176
|
-
|
177
|
-
# # # # # # # # # # # # # # # # # # # # #
|
178
|
-
# INDEXING
|
179
|
-
# # # # # # # # # # # # # # # # # # # # #
|
180
|
-
|
181
|
-
# Retrieve one object from the index
|
182
|
-
#
|
183
|
-
# @param object_id [String]
|
184
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
185
|
-
#
|
186
|
-
# @return [Hash]
|
187
|
-
#
|
188
|
-
def get_object(object_id, opts = {})
|
189
|
-
@transporter.read(:GET, path_encode('/1/indexes/%s/%s', @name, object_id), {}, opts)
|
190
|
-
end
|
191
|
-
|
192
|
-
# Retrieve one or more objects in a single API call
|
193
|
-
#
|
194
|
-
# @param object_ids [Array]
|
195
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
196
|
-
#
|
197
|
-
# @return [Hash]
|
198
|
-
#
|
199
|
-
def get_objects(object_ids, opts = {})
|
200
|
-
request_options = symbolize_hash(opts)
|
201
|
-
attributes_to_retrieve = get_option(request_options, 'attributesToRetrieve')
|
202
|
-
request_options.delete(:attributesToRetrieve)
|
203
|
-
|
204
|
-
requests = []
|
205
|
-
object_ids.each do |object_id|
|
206
|
-
request = { indexName: @name, objectID: object_id.to_s }
|
207
|
-
|
208
|
-
if attributes_to_retrieve
|
209
|
-
request[:attributesToRetrieve] = attributes_to_retrieve
|
210
|
-
end
|
211
|
-
|
212
|
-
requests.push(request)
|
213
|
-
end
|
214
|
-
|
215
|
-
@transporter.read(:POST, '/1/indexes/*/objects', { 'requests': requests }, opts)
|
216
|
-
end
|
217
|
-
|
218
|
-
# Add an object to the index
|
219
|
-
#
|
220
|
-
# @param object [Hash] the object to save
|
221
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
222
|
-
#
|
223
|
-
# @return [IndexingResponse]
|
224
|
-
#
|
225
|
-
def save_object(object, opts = {})
|
226
|
-
save_objects([object], opts)
|
227
|
-
end
|
228
|
-
|
229
|
-
# Add an object to the index and wait for operation to complete
|
230
|
-
#
|
231
|
-
# @param object [Hash] the object to save
|
232
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
233
|
-
#
|
234
|
-
# @return [IndexingResponse]
|
235
|
-
#
|
236
|
-
def save_object!(object, opts = {})
|
237
|
-
response = save_objects([object], opts)
|
238
|
-
response.wait(opts)
|
239
|
-
end
|
240
|
-
|
241
|
-
# Add several objects to the index
|
242
|
-
#
|
243
|
-
# @param objects [Array] the objects to save
|
244
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
245
|
-
#
|
246
|
-
# @return [IndexingResponse]
|
247
|
-
#
|
248
|
-
def save_objects(objects, opts = {})
|
249
|
-
request_options = symbolize_hash(opts)
|
250
|
-
generate_object_id = request_options[:auto_generate_object_id_if_not_exist] || false
|
251
|
-
request_options.delete(:auto_generate_object_id_if_not_exist)
|
252
|
-
if generate_object_id
|
253
|
-
IndexingResponse.new(self, raw_batch(chunk('addObject', objects), request_options))
|
254
|
-
else
|
255
|
-
IndexingResponse.new(self, raw_batch(chunk('updateObject', objects, true), request_options))
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# Add several objects to the index and wait for operation to complete
|
260
|
-
#
|
261
|
-
# @param objects [Array] the objects to save
|
262
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
263
|
-
#
|
264
|
-
# @return [IndexingResponse]
|
265
|
-
#
|
266
|
-
def save_objects!(objects, opts = {})
|
267
|
-
response = save_objects(objects, opts)
|
268
|
-
response.wait(opts)
|
269
|
-
end
|
270
|
-
|
271
|
-
# Partially update an object
|
272
|
-
#
|
273
|
-
# @param object [String] object ID to partially update
|
274
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
275
|
-
#
|
276
|
-
# @return [IndexingResponse]
|
277
|
-
#
|
278
|
-
def partial_update_object(object, opts = {})
|
279
|
-
partial_update_objects([object], opts)
|
280
|
-
end
|
281
|
-
|
282
|
-
# Partially update an object and wait for operation to complete
|
283
|
-
#
|
284
|
-
# @param object [String] object ID to partially update
|
285
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
286
|
-
#
|
287
|
-
# @return [IndexingResponse]
|
288
|
-
#
|
289
|
-
def partial_update_object!(object, opts = {})
|
290
|
-
response = partial_update_objects([object], opts)
|
291
|
-
response.wait(opts)
|
292
|
-
end
|
293
|
-
|
294
|
-
# Partially update several objects
|
295
|
-
#
|
296
|
-
# @param objects [Array] array of objectIDs to partially update
|
297
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
298
|
-
#
|
299
|
-
# @return [IndexingResponse]
|
300
|
-
#
|
301
|
-
def partial_update_objects(objects, opts = {})
|
302
|
-
generate_object_id = false
|
303
|
-
request_options = symbolize_hash(opts)
|
304
|
-
if get_option(request_options, 'createIfNotExists')
|
305
|
-
generate_object_id = true
|
306
|
-
end
|
307
|
-
request_options.delete(:createIfNotExists)
|
308
|
-
|
309
|
-
if generate_object_id
|
310
|
-
IndexingResponse.new(self, raw_batch(chunk('partialUpdateObject', objects), request_options))
|
311
|
-
else
|
312
|
-
IndexingResponse.new(self, raw_batch(chunk('partialUpdateObjectNoCreate', objects), request_options))
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
# Partially update several objects and wait for operation to complete
|
317
|
-
#
|
318
|
-
# @param objects [Array] array of objectIDs to partially update
|
319
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
320
|
-
#
|
321
|
-
# @return [IndexingResponse]
|
322
|
-
#
|
323
|
-
def partial_update_objects!(objects, opts = {})
|
324
|
-
response = partial_update_objects(objects, opts)
|
325
|
-
response.wait(opts)
|
326
|
-
end
|
327
|
-
|
328
|
-
# Delete an existing object from an index
|
329
|
-
#
|
330
|
-
# @param object_id [String]
|
331
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
332
|
-
#
|
333
|
-
# @return [IndexingResponse]
|
334
|
-
#
|
335
|
-
def delete_object(object_id, opts = {})
|
336
|
-
delete_objects([object_id], opts)
|
337
|
-
end
|
338
|
-
|
339
|
-
# Delete an existing object from an index and wait for operation to complete
|
340
|
-
#
|
341
|
-
# @param object_id [String]
|
342
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
343
|
-
#
|
344
|
-
# @return [IndexingResponse]
|
345
|
-
#
|
346
|
-
def delete_object!(object_id, opts = {})
|
347
|
-
response = delete_objects([object_id], opts)
|
348
|
-
response.wait(opts)
|
349
|
-
end
|
350
|
-
|
351
|
-
# Delete several existing objects from an index
|
352
|
-
#
|
353
|
-
# @param object_ids [Array]
|
354
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
355
|
-
#
|
356
|
-
# @return [IndexingResponse]
|
357
|
-
#
|
358
|
-
def delete_objects(object_ids, opts = {})
|
359
|
-
objects = object_ids.map do |object_id|
|
360
|
-
{ objectID: object_id }
|
361
|
-
end
|
362
|
-
|
363
|
-
IndexingResponse.new(self, raw_batch(chunk('deleteObject', objects), opts))
|
364
|
-
end
|
365
|
-
|
366
|
-
# Delete several existing objects from an index and wait for operation to complete
|
367
|
-
#
|
368
|
-
# @param object_ids [Array]
|
369
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
370
|
-
#
|
371
|
-
# @return [IndexingResponse]
|
372
|
-
#
|
373
|
-
def delete_objects!(object_ids, opts = {})
|
374
|
-
response = delete_objects(object_ids, opts)
|
375
|
-
response.wait(opts)
|
376
|
-
end
|
377
|
-
|
378
|
-
# Delete all records matching the query
|
379
|
-
#
|
380
|
-
# @param filters [Hash]
|
381
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
382
|
-
#
|
383
|
-
# @return [IndexingResponse]
|
384
|
-
#
|
385
|
-
def delete_by(filters, opts = {})
|
386
|
-
response = @transporter.write(:POST, path_encode('/1/indexes/%s/deleteByQuery', @name), filters, opts)
|
387
|
-
|
388
|
-
IndexingResponse.new(self, response)
|
389
|
-
end
|
390
|
-
|
391
|
-
# Delete all records matching the query and wait for operation to complete
|
392
|
-
#
|
393
|
-
# @param filters [Hash]
|
394
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
395
|
-
#
|
396
|
-
# @return [IndexingResponse]
|
397
|
-
#
|
398
|
-
def delete_by!(filters, opts = {})
|
399
|
-
response = delete_by(filters, opts)
|
400
|
-
|
401
|
-
response.wait(opts)
|
402
|
-
end
|
403
|
-
|
404
|
-
# Send a batch request
|
405
|
-
#
|
406
|
-
# @param requests [Hash] hash containing the requests to batch
|
407
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
408
|
-
#
|
409
|
-
# @return [IndexingResponse]
|
410
|
-
#
|
411
|
-
def batch(requests, opts = {})
|
412
|
-
response = raw_batch(requests, opts)
|
413
|
-
|
414
|
-
IndexingResponse.new(self, response)
|
415
|
-
end
|
416
|
-
|
417
|
-
# Send a batch request and wait for operation to complete
|
418
|
-
#
|
419
|
-
# @param requests [Hash] hash containing the requests to batch
|
420
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
421
|
-
#
|
422
|
-
# @return [IndexingResponse]
|
423
|
-
#
|
424
|
-
def batch!(requests, opts = {})
|
425
|
-
response = batch(requests, opts)
|
426
|
-
response.wait(opts)
|
427
|
-
end
|
428
|
-
|
429
|
-
# # # # # # # # # # # # # # # # # # # # #
|
430
|
-
# QUERY RULES
|
431
|
-
# # # # # # # # # # # # # # # # # # # # #
|
432
|
-
|
433
|
-
# Retrieve the Rule with the specified objectID
|
434
|
-
#
|
435
|
-
# @param object_id [String]
|
436
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
437
|
-
#
|
438
|
-
# @return [Hash]
|
439
|
-
#
|
440
|
-
def get_rule(object_id, opts = {})
|
441
|
-
@transporter.read(:GET, path_encode('/1/indexes/%s/rules/%s', @name, object_id), {}, opts)
|
442
|
-
end
|
443
|
-
|
444
|
-
# Create or update a rule
|
445
|
-
#
|
446
|
-
# @param rule [Hash] a hash containing a rule objectID and different conditions/consequences
|
447
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
448
|
-
#
|
449
|
-
# @return [Array, IndexingResponse]
|
450
|
-
#
|
451
|
-
def save_rule(rule, opts = {})
|
452
|
-
save_rules([rule], opts)
|
453
|
-
end
|
454
|
-
|
455
|
-
# Create or update a rule and wait for operation to complete
|
456
|
-
#
|
457
|
-
# @param rule [Hash] a hash containing a rule objectID and different conditions/consequences
|
458
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
459
|
-
#
|
460
|
-
# @return [Array, IndexingResponse]
|
461
|
-
#
|
462
|
-
def save_rule!(rule, opts = {})
|
463
|
-
response = save_rules([rule], opts)
|
464
|
-
response.wait(opts)
|
465
|
-
end
|
466
|
-
|
467
|
-
# Create or update rules
|
468
|
-
#
|
469
|
-
# @param rules [Array] an array of hashes containing a rule objectID and different conditions/consequences
|
470
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
471
|
-
#
|
472
|
-
# @return [Array, IndexingResponse]
|
473
|
-
#
|
474
|
-
def save_rules(rules, opts = {})
|
475
|
-
if rules.is_a?(RuleIterator)
|
476
|
-
iterated = []
|
477
|
-
rules.each do |rule|
|
478
|
-
iterated.push(rule)
|
479
|
-
end
|
480
|
-
rules = iterated
|
481
|
-
end
|
482
|
-
|
483
|
-
if rules.empty?
|
484
|
-
return []
|
485
|
-
end
|
486
|
-
|
487
|
-
forward_to_replicas = false
|
488
|
-
clear_existing_rules = false
|
489
|
-
request_options = symbolize_hash(opts)
|
490
|
-
|
491
|
-
if request_options[:forwardToReplicas]
|
492
|
-
forward_to_replicas = true
|
493
|
-
request_options.delete(:forwardToReplicas)
|
494
|
-
end
|
495
|
-
|
496
|
-
if request_options[:clearExistingRules]
|
497
|
-
clear_existing_rules = true
|
498
|
-
request_options.delete(:clearExistingRules)
|
499
|
-
end
|
500
|
-
|
501
|
-
rules.each do |rule|
|
502
|
-
get_object_id(rule)
|
503
|
-
end
|
504
|
-
|
505
|
-
response = @transporter.write(:POST, path_encode('/1/indexes/%s/rules/batch', @name) + handle_params({ forwardToReplicas: forward_to_replicas, clearExistingRules: clear_existing_rules }), rules, request_options)
|
506
|
-
|
507
|
-
IndexingResponse.new(self, response)
|
508
|
-
end
|
509
|
-
|
510
|
-
# Create or update rules and wait for operation to complete
|
511
|
-
#
|
512
|
-
# @param rules [Array] an array of hashes containing a rule objectID and different conditions/consequences
|
513
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
514
|
-
#
|
515
|
-
# @return [Array, IndexingResponse]
|
516
|
-
#
|
517
|
-
def save_rules!(rules, opts = {})
|
518
|
-
response = save_rules(rules, opts)
|
519
|
-
response.wait(opts)
|
520
|
-
end
|
521
|
-
|
522
|
-
# Delete all Rules in the index
|
523
|
-
#
|
524
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
525
|
-
#
|
526
|
-
# @return [IndexingResponse]
|
527
|
-
#
|
528
|
-
def clear_rules(opts = {})
|
529
|
-
forward_to_replicas = false
|
530
|
-
request_options = symbolize_hash(opts)
|
531
|
-
|
532
|
-
if request_options[:forwardToReplicas]
|
533
|
-
forward_to_replicas = true
|
534
|
-
request_options.delete(:forwardToReplicas)
|
535
|
-
end
|
536
|
-
|
537
|
-
response = @transporter.write(:POST, path_encode('1/indexes/%s/rules/clear', @name) + handle_params({ forwardToReplicas: forward_to_replicas }), '', request_options)
|
538
|
-
|
539
|
-
IndexingResponse.new(self, response)
|
540
|
-
end
|
541
|
-
|
542
|
-
# Delete all Rules in the index and wait for operation to complete
|
543
|
-
#
|
544
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
545
|
-
#
|
546
|
-
# @return [IndexingResponse]
|
547
|
-
#
|
548
|
-
def clear_rules!(opts = {})
|
549
|
-
response = clear_rules(opts)
|
550
|
-
response.wait(opts)
|
551
|
-
end
|
552
|
-
|
553
|
-
# Delete the Rule with the specified objectID
|
554
|
-
#
|
555
|
-
# @param object_id [String]
|
556
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
557
|
-
#
|
558
|
-
# @return [IndexingResponse]
|
559
|
-
#
|
560
|
-
def delete_rule(object_id, opts = {})
|
561
|
-
forward_to_replicas = false
|
562
|
-
request_options = symbolize_hash(opts)
|
563
|
-
|
564
|
-
if request_options[:forwardToReplicas]
|
565
|
-
forward_to_replicas = true
|
566
|
-
request_options.delete(:forwardToReplicas)
|
567
|
-
end
|
568
|
-
|
569
|
-
response = @transporter.write(
|
570
|
-
:DELETE,
|
571
|
-
path_encode('1/indexes/%s/rules/%s', @name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
|
572
|
-
'',
|
573
|
-
request_options
|
574
|
-
)
|
575
|
-
|
576
|
-
IndexingResponse.new(self, response)
|
577
|
-
end
|
578
|
-
|
579
|
-
# Delete the Rule with the specified objectID and wait for operation to complete
|
580
|
-
#
|
581
|
-
# @param object_id [String]
|
582
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
583
|
-
#
|
584
|
-
# @return [IndexingResponse]
|
585
|
-
#
|
586
|
-
def delete_rule!(object_id, opts = {})
|
587
|
-
response = delete_rule(object_id, opts)
|
588
|
-
response.wait(opts)
|
589
|
-
end
|
590
|
-
|
591
|
-
# # # # # # # # # # # # # # # # # # # # #
|
592
|
-
# SYNONYMS
|
593
|
-
# # # # # # # # # # # # # # # # # # # # #
|
594
|
-
|
595
|
-
# Fetch a synonym object identified by its objectID
|
596
|
-
#
|
597
|
-
# @param object_id [String]
|
598
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
599
|
-
#
|
600
|
-
# @return [Hash]
|
601
|
-
#
|
602
|
-
def get_synonym(object_id, opts = {})
|
603
|
-
@transporter.read(:GET, path_encode('/1/indexes/%s/synonyms/%s', @name, object_id), {}, opts)
|
604
|
-
end
|
605
|
-
|
606
|
-
# Create a new synonym object or update the existing synonym object with the given object ID
|
607
|
-
#
|
608
|
-
# @param synonym [Hash] Synonym object
|
609
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
610
|
-
#
|
611
|
-
# @return [Array, IndexingResponse]
|
612
|
-
#
|
613
|
-
def save_synonym(synonym, opts = {})
|
614
|
-
save_synonyms([synonym], opts)
|
615
|
-
end
|
616
|
-
|
617
|
-
# Create a new synonym object or update the existing synonym object with the given object ID
|
618
|
-
# and wait for operation to finish
|
619
|
-
#
|
620
|
-
# @param synonym [Hash] Synonym object
|
621
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
622
|
-
#
|
623
|
-
# @return [Array, IndexingResponse]
|
624
|
-
#
|
625
|
-
def save_synonym!(synonym, opts = {})
|
626
|
-
response = save_synonyms([synonym], opts)
|
627
|
-
response.wait(opts)
|
628
|
-
end
|
629
|
-
|
630
|
-
# Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if
|
631
|
-
# replaceExistingSynonyms is true
|
632
|
-
#
|
633
|
-
# @param synonyms [Array] Array of Synonym objects
|
634
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
635
|
-
#
|
636
|
-
# @return [Array, IndexingResponse]
|
637
|
-
#
|
638
|
-
def save_synonyms(synonyms, opts = {})
|
639
|
-
if synonyms.is_a?(SynonymIterator)
|
640
|
-
iterated = []
|
641
|
-
synonyms.each do |synonym|
|
642
|
-
iterated.push(synonym)
|
643
|
-
end
|
644
|
-
synonyms = iterated
|
645
|
-
end
|
646
|
-
|
647
|
-
if synonyms.empty?
|
648
|
-
return []
|
649
|
-
end
|
650
|
-
|
651
|
-
synonyms.each do |synonym|
|
652
|
-
get_object_id(synonym)
|
653
|
-
end
|
654
|
-
|
655
|
-
forward_to_replicas = false
|
656
|
-
replace_existing_synonyms = false
|
657
|
-
|
658
|
-
request_options = symbolize_hash(opts)
|
659
|
-
|
660
|
-
if request_options[:forwardToReplicas]
|
661
|
-
forward_to_replicas = true
|
662
|
-
request_options.delete(:forwardToReplicas)
|
663
|
-
end
|
664
|
-
|
665
|
-
if request_options[:replaceExistingSynonyms]
|
666
|
-
replace_existing_synonyms = true
|
667
|
-
request_options.delete(:replaceExistingSynonyms)
|
668
|
-
end
|
669
|
-
response = @transporter.write(
|
670
|
-
:POST,
|
671
|
-
path_encode('/1/indexes/%s/synonyms/batch', @name) + handle_params({ forwardToReplicas: forward_to_replicas, replaceExistingSynonyms: replace_existing_synonyms }),
|
672
|
-
synonyms,
|
673
|
-
request_options
|
674
|
-
)
|
675
|
-
|
676
|
-
IndexingResponse.new(self, response)
|
677
|
-
end
|
678
|
-
|
679
|
-
# Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if
|
680
|
-
# replaceExistingSynonyms is true and wait for operation to complete
|
681
|
-
#
|
682
|
-
# @param synonyms [Array] Array of Synonym objects
|
683
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
684
|
-
#
|
685
|
-
# @return [Array, IndexingResponse]
|
686
|
-
#
|
687
|
-
def save_synonyms!(synonyms, opts = {})
|
688
|
-
response = save_synonyms(synonyms, opts)
|
689
|
-
response.wait(opts)
|
690
|
-
end
|
691
|
-
|
692
|
-
# Delete all synonyms from the index
|
693
|
-
#
|
694
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
695
|
-
#
|
696
|
-
# @return [IndexingResponse]
|
697
|
-
#
|
698
|
-
def clear_synonyms(opts = {})
|
699
|
-
forward_to_replicas = false
|
700
|
-
request_options = symbolize_hash(opts)
|
701
|
-
|
702
|
-
if request_options[:forwardToReplicas]
|
703
|
-
forward_to_replicas = true
|
704
|
-
request_options.delete(:forwardToReplicas)
|
705
|
-
end
|
706
|
-
response = @transporter.write(
|
707
|
-
:POST,
|
708
|
-
path_encode('1/indexes/%s/synonyms/clear', @name) + handle_params({ forwardToReplicas: forward_to_replicas }),
|
709
|
-
'',
|
710
|
-
request_options
|
711
|
-
)
|
712
|
-
|
713
|
-
IndexingResponse.new(self, response)
|
714
|
-
end
|
715
|
-
|
716
|
-
# Delete all synonyms from the index and wait for operation to complete
|
717
|
-
#
|
718
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
719
|
-
#
|
720
|
-
# @return [IndexingResponse]
|
721
|
-
#
|
722
|
-
def clear_synonyms!(opts = {})
|
723
|
-
response = clear_synonyms(opts)
|
724
|
-
response.wait(opts)
|
725
|
-
end
|
726
|
-
|
727
|
-
# Delete a single synonyms set, identified by the given objectID
|
728
|
-
#
|
729
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
730
|
-
#
|
731
|
-
# @return [IndexingResponse]
|
732
|
-
#
|
733
|
-
def delete_synonym(object_id, opts = {})
|
734
|
-
forward_to_replicas = false
|
735
|
-
request_options = symbolize_hash(opts)
|
736
|
-
|
737
|
-
if request_options[:forwardToReplicas]
|
738
|
-
forward_to_replicas = true
|
739
|
-
request_options.delete(:forwardToReplicas)
|
740
|
-
end
|
741
|
-
response = @transporter.write(
|
742
|
-
:DELETE,
|
743
|
-
path_encode('1/indexes/%s/synonyms/%s', @name, object_id) + handle_params({ forwardToReplicas: forward_to_replicas }),
|
744
|
-
'',
|
745
|
-
request_options
|
746
|
-
)
|
747
|
-
|
748
|
-
IndexingResponse.new(self, response)
|
749
|
-
end
|
750
|
-
|
751
|
-
# Delete a single synonyms set, identified by the given objectID and wait for operation to complete
|
752
|
-
#
|
753
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
754
|
-
#
|
755
|
-
# @return [IndexingResponse]
|
756
|
-
#
|
757
|
-
def delete_synonym!(object_id, opts = {})
|
758
|
-
response = delete_synonym(object_id, opts)
|
759
|
-
response.wait(opts)
|
760
|
-
end
|
761
|
-
|
762
|
-
# # # # # # # # # # # # # # # # # # # # #
|
763
|
-
# BROWSING
|
764
|
-
# # # # # # # # # # # # # # # # # # # # #
|
765
|
-
|
766
|
-
# Browse all index content
|
767
|
-
#
|
768
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
769
|
-
#
|
770
|
-
# @return [Enumerator, ObjectIterator]
|
771
|
-
#
|
772
|
-
def browse_objects(opts = {}, &block)
|
773
|
-
if block_given?
|
774
|
-
ObjectIterator.new(@transporter, @name, opts).each(&block)
|
775
|
-
else
|
776
|
-
ObjectIterator.new(@transporter, @name, opts)
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
# Browse all rules
|
781
|
-
#
|
782
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
783
|
-
#
|
784
|
-
# @return [Enumerator, RuleIterator]
|
785
|
-
#
|
786
|
-
def browse_rules(opts = {}, &block)
|
787
|
-
if block_given?
|
788
|
-
RuleIterator.new(@transporter, @name, opts).each(&block)
|
789
|
-
else
|
790
|
-
RuleIterator.new(@transporter, @name, opts)
|
791
|
-
end
|
792
|
-
end
|
793
|
-
|
794
|
-
# Browse all synonyms
|
795
|
-
#
|
796
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
797
|
-
#
|
798
|
-
# @return [Enumerator, SynonymIterator]
|
799
|
-
#
|
800
|
-
def browse_synonyms(opts = {}, &block)
|
801
|
-
if block_given?
|
802
|
-
SynonymIterator.new(@transporter, @name, opts).each(&block)
|
803
|
-
else
|
804
|
-
SynonymIterator.new(@transporter, @name, opts)
|
805
|
-
end
|
806
|
-
end
|
807
|
-
|
808
|
-
# # # # # # # # # # # # # # # # # # # # #
|
809
|
-
# REPLACING
|
810
|
-
# # # # # # # # # # # # # # # # # # # # #
|
811
|
-
|
812
|
-
# Replace all objects in the index
|
813
|
-
#
|
814
|
-
# @param objects [Array] Array of objects
|
815
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
816
|
-
#
|
817
|
-
# @return [Enumerator, SynonymIterator]
|
818
|
-
#
|
819
|
-
def replace_all_objects(objects, opts = {})
|
820
|
-
safe = false
|
821
|
-
request_options = symbolize_hash(opts)
|
822
|
-
if request_options[:safe]
|
823
|
-
safe = true
|
824
|
-
request_options.delete(:safe)
|
825
|
-
end
|
826
|
-
|
827
|
-
tmp_index_name = @name + '_tmp_' + rand(10000000).to_s
|
828
|
-
copy_to_response = copy_to(tmp_index_name, request_options.merge({ scope: %w(settings synonyms rules) }))
|
829
|
-
|
830
|
-
if safe
|
831
|
-
copy_to_response.wait
|
832
|
-
end
|
833
|
-
|
834
|
-
# TODO: consider create a new client with state of retry is shared
|
835
|
-
tmp_client = Algolia::Search::Client.new(@config, { logger: logger })
|
836
|
-
tmp_index = tmp_client.init_index(tmp_index_name)
|
837
|
-
|
838
|
-
save_objects_response = tmp_index.save_objects(objects, request_options)
|
839
|
-
|
840
|
-
if safe
|
841
|
-
save_objects_response.wait
|
842
|
-
end
|
843
|
-
|
844
|
-
move_to_response = tmp_index.move_to(@name)
|
845
|
-
if safe
|
846
|
-
move_to_response.wait
|
847
|
-
end
|
848
|
-
end
|
849
|
-
|
850
|
-
# Replace all objects in the index and wait for the operation to complete
|
851
|
-
#
|
852
|
-
# @param objects [Array] Array of objects
|
853
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
854
|
-
#
|
855
|
-
# @return [Enumerator, SynonymIterator]
|
856
|
-
#
|
857
|
-
def replace_all_objects!(objects, opts = {})
|
858
|
-
replace_all_objects(objects, opts.merge(safe: true))
|
859
|
-
end
|
860
|
-
|
861
|
-
# Replace all rules in the index
|
862
|
-
#
|
863
|
-
# @param rules [Array] Array of rules
|
864
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
865
|
-
#
|
866
|
-
# @return [Array, IndexingResponse]
|
867
|
-
#
|
868
|
-
def replace_all_rules(rules, opts = {})
|
869
|
-
request_options = symbolize_hash(opts)
|
870
|
-
request_options[:clearExistingRules] = true
|
871
|
-
|
872
|
-
save_rules(rules, request_options)
|
873
|
-
end
|
874
|
-
|
875
|
-
# Replace all rules in the index and wait for the operation to complete
|
876
|
-
#
|
877
|
-
# @param rules [Array] Array of rules
|
878
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
879
|
-
#
|
880
|
-
# @return [Array, IndexingResponse]
|
881
|
-
#
|
882
|
-
def replace_all_rules!(rules, opts = {})
|
883
|
-
request_options = symbolize_hash(opts)
|
884
|
-
request_options[:clearExistingRules] = true
|
885
|
-
|
886
|
-
save_rules!(rules, request_options)
|
887
|
-
end
|
888
|
-
|
889
|
-
# Replace all synonyms in the index
|
890
|
-
#
|
891
|
-
# @param synonyms [Array] Array of synonyms
|
892
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
893
|
-
#
|
894
|
-
# @return [Array, IndexingResponse]
|
895
|
-
#
|
896
|
-
def replace_all_synonyms(synonyms, opts = {})
|
897
|
-
request_options = symbolize_hash(opts)
|
898
|
-
request_options[:replaceExistingSynonyms] = true
|
899
|
-
|
900
|
-
save_synonyms(synonyms, request_options)
|
901
|
-
end
|
902
|
-
|
903
|
-
# Replace all synonyms in the index and wait for the operation to complete
|
904
|
-
#
|
905
|
-
# @param synonyms [Array] Array of synonyms
|
906
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
907
|
-
#
|
908
|
-
# @return [Array, IndexingResponse]
|
909
|
-
#
|
910
|
-
def replace_all_synonyms!(synonyms, opts = {})
|
911
|
-
request_options = symbolize_hash(opts)
|
912
|
-
request_options[:replaceExistingSynonyms] = true
|
913
|
-
|
914
|
-
save_synonyms!(synonyms, request_options)
|
915
|
-
end
|
916
|
-
|
917
|
-
# # # # # # # # # # # # # # # # # # # # #
|
918
|
-
# SEARCHING
|
919
|
-
# # # # # # # # # # # # # # # # # # # # #
|
920
|
-
|
921
|
-
# Perform a search on the index
|
922
|
-
#
|
923
|
-
# @param query the full text query
|
924
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
925
|
-
#
|
926
|
-
# @return [Hash]
|
927
|
-
#
|
928
|
-
def search(query, opts = {})
|
929
|
-
@transporter.read(:POST, path_encode('/1/indexes/%s/query', @name), { 'query': query.to_s }, opts)
|
930
|
-
end
|
931
|
-
|
932
|
-
# Search for values of a given facet, optionally restricting the returned values to those contained
|
933
|
-
# in objects matching other search criteria
|
934
|
-
#
|
935
|
-
# @param facet_name [String]
|
936
|
-
# @param facet_query [String]
|
937
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
938
|
-
#
|
939
|
-
# @return [Hash]
|
940
|
-
#
|
941
|
-
def search_for_facet_values(facet_name, facet_query, opts = {})
|
942
|
-
@transporter.read(:POST, path_encode('/1/indexes/%s/facets/%s/query', @name, facet_name),
|
943
|
-
{ 'facetQuery': facet_query }, opts)
|
944
|
-
end
|
945
|
-
|
946
|
-
# Search or browse all synonyms, optionally filtering them by type
|
947
|
-
#
|
948
|
-
# @param query [String] Search for specific synonyms matching this string
|
949
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
950
|
-
#
|
951
|
-
# @return [Hash]
|
952
|
-
#
|
953
|
-
def search_synonyms(query, opts = {})
|
954
|
-
@transporter.read(:POST, path_encode('/1/indexes/%s/synonyms/search', @name), { query: query.to_s }, opts)
|
955
|
-
end
|
956
|
-
|
957
|
-
# Search or browse all rules, optionally filtering them by type
|
958
|
-
#
|
959
|
-
# @param query [String] Search for specific rules matching this string
|
960
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
961
|
-
#
|
962
|
-
# @return [Hash]
|
963
|
-
#
|
964
|
-
def search_rules(query, opts = {})
|
965
|
-
@transporter.read(:POST, path_encode('/1/indexes/%s/rules/search', @name), { query: query.to_s }, opts)
|
966
|
-
end
|
967
|
-
|
968
|
-
# # # # # # # # # # # # # # # # # # # # #
|
969
|
-
# SETTINGS
|
970
|
-
# # # # # # # # # # # # # # # # # # # # #
|
971
|
-
|
972
|
-
# Retrieve index settings
|
973
|
-
#
|
974
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
975
|
-
#
|
976
|
-
# @return [Hash]
|
977
|
-
#
|
978
|
-
def get_settings(opts = {})
|
979
|
-
opts_default = {
|
980
|
-
getVersion: 2
|
981
|
-
}
|
982
|
-
opts = opts_default.merge(opts)
|
983
|
-
response = @transporter.read(:GET, path_encode('/1/indexes/%s/settings', @name), {}, opts)
|
984
|
-
|
985
|
-
deserialize_settings(response, @config.symbolize_keys)
|
986
|
-
end
|
987
|
-
|
988
|
-
# Update some index settings. Only specified settings are overridden
|
989
|
-
#
|
990
|
-
# @param settings [Hash] the settings to update
|
991
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
992
|
-
#
|
993
|
-
# @return [IndexingResponse]
|
994
|
-
#
|
995
|
-
def set_settings(settings, opts = {})
|
996
|
-
request_options = symbolize_hash(opts)
|
997
|
-
forward_to_replicas = request_options.delete(:forwardToReplicas) || false
|
998
|
-
|
999
|
-
response = @transporter.write(
|
1000
|
-
:PUT,
|
1001
|
-
path_encode('/1/indexes/%s/settings', @name) + handle_params({ forwardToReplicas: forward_to_replicas }),
|
1002
|
-
settings,
|
1003
|
-
request_options
|
1004
|
-
)
|
1005
|
-
|
1006
|
-
IndexingResponse.new(self, response)
|
1007
|
-
end
|
1008
|
-
|
1009
|
-
# Update some index settings and wait for operation to complete.
|
1010
|
-
# Only specified settings are overridden
|
1011
|
-
#
|
1012
|
-
# @param settings [Hash] the settings to update
|
1013
|
-
# @param opts [Hash] contains extra parameters to send with your query
|
1014
|
-
#
|
1015
|
-
# @return [IndexingResponse]
|
1016
|
-
#
|
1017
|
-
def set_settings!(settings, opts = {})
|
1018
|
-
response = set_settings(settings, opts)
|
1019
|
-
response.wait(opts)
|
1020
|
-
end
|
1021
|
-
|
1022
|
-
# # # # # # # # # # # # # # # # # # # # #
|
1023
|
-
# EXISTS
|
1024
|
-
# # # # # # # # # # # # # # # # # # # # #
|
1025
|
-
|
1026
|
-
# Checks if the current index exists
|
1027
|
-
#
|
1028
|
-
# @return [Boolean]
|
1029
|
-
#
|
1030
|
-
def exists
|
1031
|
-
begin
|
1032
|
-
get_settings
|
1033
|
-
rescue AlgoliaHttpError => e
|
1034
|
-
if e.code == 404
|
1035
|
-
return false
|
1036
|
-
end
|
1037
|
-
|
1038
|
-
raise e
|
1039
|
-
end
|
1040
|
-
true
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
#
|
1044
|
-
# Aliases the exists method
|
1045
|
-
#
|
1046
|
-
alias_method :exists?, :exists
|
1047
|
-
|
1048
|
-
# # # # # # # # # # # # # # # # # # # # #
|
1049
|
-
# PRIVATE
|
1050
|
-
# # # # # # # # # # # # # # # # # # # # #
|
1051
|
-
|
1052
|
-
private
|
1053
|
-
|
1054
|
-
def raw_batch(requests, opts)
|
1055
|
-
@transporter.write(:POST, path_encode('/1/indexes/%s/batch', @name), { requests: requests }, opts)
|
1056
|
-
end
|
1057
|
-
end
|
1058
|
-
end
|
1059
|
-
end
|