Skip to content

[JAY-676] Introducing querying / pushing to multiple indexes at the same time#35

Merged
sergio-bobillier merged 6 commits into
masterfrom
sb-multi-index
Aug 22, 2025
Merged

[JAY-676] Introducing querying / pushing to multiple indexes at the same time#35
sergio-bobillier merged 6 commits into
masterfrom
sb-multi-index

Conversation

@sergio-bobillier

Copy link
Copy Markdown
Collaborator

The changes in this pull request will add an API that allows the user to query or push data to multiple indexes at the same time. The changes in terms of actual logic are really small since many of the methods of the underlying Elasticsearch client can take multiple indexes.

In order to accomplish this the following changes are being introduced:

  • The common logic is being moved up to the Indexable mixin.
  • To maintain backwards compatibility, a small amount of logic is being added to the Index class. Mainly to allow it to take the same parameters and return the same types for all the methods it already had.
  • The new Indexes class is being added. This class has almost no logic since the core logic in the Indexable mixin is taking care of everything. The class is being introduced only for mnemonic purposes. I.e. to make the difference between working with one and multiple indexes obvious.

Comment thread lib/jay_api/elasticsearch/indexable.rb
Comment thread lib/jay_api/elasticsearch/indexable.rb Outdated
Comment thread lib/jay_api/elasticsearch/indexable.rb Outdated
Comment thread lib/jay_api/elasticsearch/indexable.rb Outdated
Comment thread lib/jay_api/elasticsearch/indexable.rb
Comment thread lib/jay_api/elasticsearch/index.rb Outdated
Comment thread lib/jay_api/elasticsearch/index.rb
Creates the Indexable mixin and moves much of the code from the
Elasticsearch::Index class there. These methods can actually be used
with a single index or with multiple indexes.

In an upcoming commit these methods will be used by another class which
will allow multiple indexes to be searched. Data could also be pushed to
multiple indexes at the same time.
Moves the test code for the methods that were moved to the Indexable
mixin to a shared examples file. This test code will be used in an
upcoming commit in order to test other classes that include the mixin.

Note: Some changes were made to the test code in order to allow it to
work in a shared_examples / shared_context block. These changes are
mainly inconsequential, for example, moving the parameters of a method
call to a separate let.
This is possible because some of the methods of the underlying
Elasticsearch client can accept and act over multiple indexes.

For those that can only act over a single index, like #index and #bulk
extra logic is added to handle this on the Jay API side.

In order to keep backwards compatibility a small amount of logic is
added to the Index class so that the constructor parameters and the
return values of the methods can stay the same.
The class represents a set of Elasticsearch indexes. Through the class
it is possible to query multiple indexes or push data to them at the
same time.

The class doesn't really add any logic. All the functional logic is just
taken from the Indexable mixin.

Because of the way the #push method works. When the batch_size is not a
multiple of the number of indexes it is possible for the pushed batch
to be slightly bigger than batch_size. Hence a Warning is logged when
this condition is detected by the Indexes class's constructor.
Changes the documentation for some methods to make it clear that they
can actually take any class which includes the Indexable mixin as
opposed to requiring explicitly an Elasticsearch::Index object.
Adds documentation about the Indexable mixin and the classes that
include it.

Just like in previous commits the common elements are being moved to a
shared place, in this case, the documentation for Index now resides in
the documentation page for Indexable.
@sergio-bobillier sergio-bobillier merged commit 3f28399 into master Aug 22, 2025
3 checks passed
@sergio-bobillier sergio-bobillier deleted the sb-multi-index branch August 22, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants