Skip to content

Elasticsearch versioned schema for Snippet

Mark Chao requested to merge 328-versioned-search into master

The CE port is at: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31465

What does this MR do?

Allows multiple versioned elasticsearch instances/schemas to work in the same code base.

This MR is a proof of concept/foundation change focusing on Snippet. The search related logic from SnippetSearch module to V12p1::SnippetClassProxy and V12p1::SnippetInstanceProxy.

The following diagram represents a comparison of the old (top) and the new approach (bottom). Grey text represents elasticsearch-rails classes.

elasticsearch.svg

Now, a call to model.__elasticsearch__.foo would be forwarded to:

  • one applicable version, if foo is a read method
  • multiple applicable versions, if foo is a write method

We can also call model.__elasticsearch__.version('V12p1').foo to trigger the method in the particular version of proxy.

Currently the versions are hardcoded to the latest version though. We need to create a table to record the versions. I've left this to another issue. The table would consist of the following fields:

  • version (e.g. 'V12p1')
  • read (boolean which can only be one)
  • write (boolean which can be many)
  • port (integer of the port the version should be connected to)

After this other ActiveModels can be migrated in a similar fashion.

Note that PersonalSnippet indexing does not work prior to this: https://gitlab.com/gitlab-org/gitlab-ee/issues/11328

Related to #328 (closed)

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Edited by Mark Chao

Merge request reports