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
Description
The
Meilisearch::Indexclass 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:
Internally, the
Meilisearch::Indexclass would include separate modules:Each self-contained module would live under the
Meilisearch::Indexclass namespace (e.g.Meilisearch::Index::Documents,Meilisearch::Index::Search):