Haystack EU 2023: Learnings and reflections from our team
If you have built search experiences, you know creating a great search experience is a never ending process: the data ...
Senior ML Engineer
If you have built search experiences, you know creating a great search experience is a never ending process: the data ...
Senior ML Engineer
Just as with a school kid who’s left unsupervised when their teacher steps outside to deal with a distraction ...
Search and Discovery writer
Back in May 2014, we added support for synonyms inside Algolia. We took our time to really nail the details ...
Technical Writer
You’re running an ecommerce site for an electronics retailer, and you’re seeing in your analytics that users keep ...
Technical Writer
What do OpenAI and DeepMind have in common? Give up? These innovative organizations both utilize technology known as transformer models ...
Sr. SEO Web Digital Marketing Manager
As a successful in-store boutique manager in 1994, you might have had your merchandisers adorn your street-facing storefront ...
Search and Discovery writer
At Algolia, our business is more than search and discovery, it’s the continuous improvement of site search. If you ...
JavaScript Library Developer
Analytics brings math and data into the otherwise very subjective world of ecommerce. It helps companies quantify how well their ...
Technical Writer
Amid all the momentous developments in the generative AI data space, are you a data scientist struggling to make sense ...
Sr. SEO Web Digital Marketing Manager
Fashion ideas for guest aunt informal summer wedding Funny movie to get my bored high-schoolers off their addictive gaming ...
Sr. SEO Web Digital Marketing Manager
Imagine you're visiting an online art gallery and a specific painting catches your eye. You'd like to find ...
Senior Software Engineer
At Algolia, our commitment to making a positive impact extends far beyond the digital landscape. We believe in the power ...
Senior Manager, People Success
In today’s post-pandemic-yet-still-super-competitive retail landscape, gaining, keeping, and converting ecommerce customers is no easy ...
Sr. SEO Web Digital Marketing Manager
There are few atmospheres as unique as that of a conference exhibit hall: the air always filled with an indescribable ...
Marketing Content Manager
To consider the question of what vectors are, it helps to be a mathematician, or at least someone who’s ...
Search and Discovery writer
My first foray into programming was writing Python on a Raspberry Pi to flicker some LED lights — it wasn’t ...
Technical Writer
How well do you know the world of modern ecommerce? With retail ecommerce sales having exceeded $5.7 trillion worldwide ...
Sr. SEO Web Digital Marketing Manager
In a world of artificial intelligence (AI), data serves as the foundation for machine learning (ML) models to identify trends ...
Director of AI Engineering
Good news in the Algoliasphere: we just released a new major version of our Ruby Client. Did you know that the Ruby client was the very first we designed? Version 1.1.3 went out almost seven years ago! It did deserve some new fresh air, to say the least. This new version gets a brand new design and brings you tons of new features, along with being 100% compliant with Common API clients specifications. Let’s dig into this.
The first thing you may notice is that we changed the name of our gem. Our Ruby Client now offers several distinct clients, for the different features of Algolia: Search of course, but also Analytics, Insights, and Recommendation. Because of this change, it only made sense for the gem to reflect the new architecture and to rename it simply “algolia”.
Using the full potential of our whole REST API is now a piece of cake, as you only have to instantiate your client of choice and use the endpoints we tailored for you. They all rely on our retry strategy to offer you the best possible experience (more on this later)
We used the opportunity of the revamp to use state-of-the art-tooling in the Ruby community. Rake tasks handle the tests and linting. Linting is done with Rubocop, and testing with Minitest. We chose Minitest over Rspec for a simple reason: it was the only one providing the possibility of parallel testing. We wanted to make sure our client was compatible with JRuby so multi-threading is not looked over, and Minitest parallel testing assures us that everything is going smoothly. Also, all methods are documented using the Yard convention.
The minimum supported Ruby version is 2.2. It’s a version still widely used among our users, and it’s the least supported Ruby version in the previous version of Rails, v5.
To give you the best Algolis experience and offer you a robust client, we now implement the same Retry Strategy used in all our other clients. It’s the key element to ensure maximum service availability, and because it’s implemented as its separate class, it’s been thoroughly unit tested and works as a system on its own. It also means you can benefit from it in all our different client instances, and even in the event you decide not to use our bundled HTTP Client. Because yes, you’re free to use whatever HTTP client you prefer!
This client is easily customizable. The most important things for us when we build our API clients are reliability and Developer eXperience (DX). We want you to be able to use our services with confidence, but also in the way you feel the most comfortable with. In that vein, you can override our requester, you can override our logger, and if you choose to stick with the requester we provide, Faraday, you can also override the adapter you’ll use with it. This is the reason why we chose Faraday as our default HTTP library. Not only was it a joy to implement, but it’s popular and frequently updated, and it answers that need for flexibility we aim to provide you. The default adapter we ship with it is Nett:Http:Persistent, but you can easily switch it for your favorite HTTP library (Excon, HTTPClient, or httpx to name a few).
We simplified the way we handle optional parameters. Now, only mandatory parameters are expected in the method signature, and everything else can be passed in the last optional parameter as a hash. If you want to pass headers, timeout, connect_timeout or compression_type, you have to set them explicitly. The rest can be passed as is! It shortens the method signatures and also aligns with our others dynamically typed clients, like Python or PHP.
We’ve added dedicated classes for configuration. This is where you can set timeouts, headers, and specific configuration for each client. Those configurations used to be set directly in the client, but now they have their dedicated class to make them easier to tweak, and separate the logic of each aspect of the clients where it belongs. For example, you can override the default hosts in the search config.
The Search Client class has been cleaned up. In addition to handling the configuration separately, we also removed the Protocol class: now you can read the endpoints being hit directly in the main class, and get a better understanding of what’s going on under the hood. Most importantly, it is not a singleton instance anymore: you create your client by passing it your app ID and API key. This instance will run on its requester and pool of connections, and won’t interfere with any other instances running at the same time.
The Search Index class remains mostly unchanged. As we mentioned before, the main improvement was to shorten the methods’ signatures by putting all the optional parameters in one single hash. As it was a really appreciated feature, we kept the bang methods to let you wait for the whole operation to finish. You can also do it the way we’re doing in the other clients, by chaining the `wait()` method after your call.
We got rid of the main pain points of the current Ruby client, the Singleton instance of the search client, and the fact that our Ruby Client was not aligned with our common specs. We now have a new base compliant with Algolia standards, with Ruby standards, and following the CTS with extra unit tests. We hope you’ll enjoy using this v2 as much as we enjoyed building it! If you want to get an exhaustive list of all the changes made, please refer to our Upgrade Guide.
Thank you for reading!
Create a full-featured search experience in no time.
Powered by Algolia Recommend