meilisearch / meilisearch/meilisearch-ruby

Refactor `Meilisearch::Index` class

Open
#676 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
224
Forks
54
PR merge metrics
No merged PRs in 30d

Description

Description

The Meilisearch::Index class is over 1400 lines long and handles too many responsibilities: documents, search, facet search, settings, stats, and compaction. This makes it difficult to navigate, maintain, and review changes.

The class can be split into focused modules, each responsible for a specific area of the API, without breaking the public interface.

Basic example

All public methods continue to work without changes:

index = client.index('movies')
index.add_documents([{ id: 1, title: 'Cloud Atlas' }])
index.search('cloud')
index.settings

Internally, the Meilisearch::Index class would include separate modules:

module Meilisearch
  class Index < HTTPRequest
    require 'meilisearch/index/documents'
    require 'meilisearch/index/search'
    require 'meilisearch/index/settings'
    # ...
  end
end

Each self-contained module would live under the Meilisearch::Index class namespace (e.g. Meilisearch::Index::Documents, Meilisearch::Index::Search):

# lib/meilisearch/index/search.rb
module Meilisearch
  class Index
    module Search
    end

    include Search
  end
end

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the current Meilisearch::Index implementation and compare its responsibilities with the proposed modules under lib/meilisearch/index/, including search.rb. Group the existing methods by the named areas while preserving the public interface, then run the existing test suite; done means the documented add_documents, search, and settings calls continue to work unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.