-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade to newest API client version #449
Open
DevinCodes
wants to merge
40
commits into
master
Choose a base branch
from
DI-2995
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
2578da0
chore: update algolia version
DevinCodes 9b1c417
WIP: fix tests until FowardToReplicas
DevinCodes bc80b19
chore: fix SubReplicas tests
DevinCodes c32aed4
chore: fix Book tests
DevinCodes 4cc7e77
chore: fix pagination tests
DevinCodes fb27573
chore: fix disabled indexing tests
DevinCodes 8ac0225
fix tests
DevinCodes b6ea1a3
ensure latest gem version
DevinCodes bc48f9a
fix: virtual replica test
DevinCodes 7998182
test matrix
DevinCodes c41e65d
Update Gemfile
DevinCodes bfe1a89
Update config.yml
DevinCodes 99e68db
Update Gemfile
DevinCodes 544278f
Update config.yml
DevinCodes f5f0e3d
Update config.yml
DevinCodes a7f2952
Update algoliasearch-rails.rb
DevinCodes 2e25bb1
sanitizer
DevinCodes d158342
Update algoliasearch-rails.rb
DevinCodes 9e698f4
Update algoliasearch-rails.rb
DevinCodes 74413b0
Update algoliasearch-rails.rb
DevinCodes 5b6af12
Update pagy.rb
DevinCodes f421f52
Update integration_spec.rb
DevinCodes dbbcc76
Update pagy.rb
DevinCodes 1ecad6c
Update integration_spec.rb
DevinCodes 1bba7f3
Update pagy.rb
DevinCodes 8a32e9b
Update pagy.rb
DevinCodes 2836446
Update integration_spec.rb
DevinCodes 91ccfc5
Update integration_spec.rb
DevinCodes 079c71d
sanitizer
DevinCodes cd3c1de
chore: clean up algoliasearch/configuration
DevinCodes 531d98a
remove `index` method
DevinCodes ab2d74b
chore: handle todos
DevinCodes 8338b52
Update algoliasearch-rails.gemspec
DevinCodes 7c56ebe
Update spec_helper.rb
DevinCodes fc5e4a1
address feedback
DevinCodes 1d81f47
feat: allow setting user agent
DevinCodes 72998fd
pin version
DevinCodes 5b3ceea
Update algoliasearch-rails.gemspec
DevinCodes 54e696f
Update config.yml
DevinCodes b23f7f2
prep release
DevinCodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Version 3 of the `algoliasearch-rails` gem replaces the Algolia API client version in use from version 2 to version 3. | ||
These versions of the API client differ significantly, so you likely need to make code changes when updating. | ||
We've tried keeping most of the changes internal, but there are still some breaking changes you need to be aware of when upgrading. | ||
|
||
If you encounter any breaking changes to the Rail integration that are not listed here, please open a Pull Request to add them to this list. | ||
|
||
## Breaking changes | ||
|
||
`algolia_ensure_init` (this method is protected and shouldn't be called manually, but we list it here anyways): the method no longer returns an initialized `index` object as this is not part of the new API client. The method now returns nothing, but it still ensures the index exists and applies settings if needed. | ||
|
||
--- | ||
`Model.search`, `Model.raw_search`: response keys in the new API client are no longer strings, but are *always* symbols. For example: | ||
```ruby | ||
# Before | ||
results = Product.raw_search('shirt') | ||
p results['hits'] | ||
|
||
# After | ||
results = Product.raw_search('shirt') | ||
p results[:hits] | ||
``` | ||
--- | ||
`Model.search_for_facet_values`: this no longer returns an array of hashes, but an array of objects of type `Algolia::Search::FacetHits`: | ||
```ruby | ||
# Before | ||
facets = Color.search_for_facet_values('short_name', 'bl', :query => 'black') | ||
puts facets.first['value'] | ||
|
||
# After | ||
facets = Color.search_for_facet_values('short_name', 'bl', :query => 'black') | ||
facets.first.value | ||
``` | ||
|
||
--- | ||
`Model.index_name` takes an additional, optional parameter. You can use this if you want to get the name of one of your replica indices, which ensures the index naming takes configuration that modifies the index name into account. | ||
For example, if you have the `:per_environment` option set to true, it will automatically add the environment name in the index name. | ||
```ruby | ||
def Product | ||
include AlgoliaSearch | ||
|
||
algoliasearch({ per_environment: true }) do | ||
add_replica 'Suits', per_environment: true do | ||
# replica settings | ||
end | ||
end | ||
|
||
end | ||
main_index_name = Product.index_name | ||
replica_index_name = Product.index_name('Suits') | ||
``` | ||
|
||
--- | ||
`AlgoliaSearch::Configuration.client_opts`, `AlgoliaSearch::Configuration::REQUIRED_CONFIGURATION` and `AlgoliaSearch::SafeIndex` have been removed. | ||
If you need to configure the API client other than the ways that are provided now, it's recommended to set up an instance manually. | ||
|
||
--- | ||
`Model.index` and `Model.algolia_index` have been removed, as there is no notion of an `Index` object in the new version of the API clients. | ||
Instead, you can use `Model.index_name` to get the name of the index to target, and use this on an instance of the API client directly. | ||
|
||
```ruby | ||
# Before | ||
res = Product.index.search('shoe') | ||
|
||
# After | ||
res = AlgoliaSearch.client.search_single_index(Product.index_name, { query: 'shoe' }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first time I'm seeing it written like it's pronounced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, yes this is for a gem named
sequel
😄