Commit 0fb9dd95 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'jprovazn-elastic-inherited' into 'master'

Override elasticsearch setting for STI note models

Closes #5705

See merge request gitlab-org/gitlab-ee!6736
parents cd316bf4 0e8b6e4f
......@@ -4,11 +4,6 @@
#
# A note of this type can be resolvable.
class DiffNote < Note
# Elastic search configuration (it does not support STI properly)
document_type 'note'
index_name [Rails.application.class.parent_name.downcase, Rails.env].join('-')
include Elastic::NotesSearch
include NoteOnDiff
include Gitlab::Utils::StrongMemoize
......
......@@ -357,6 +357,23 @@ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
If all items are green, then congratulations, the upgrade is complete!
### 16. Elasticsearch index update (if you currently use Elasticsearch)
In 11.2 release we fixed a bug that caused some types of notes to not be indexed. Please re-create your index by using one of two ways listed below:
1. Re-create the index. The following command is acceptable for not very big GitLab instances (storage size no more than few gigabytes).
```
# Omnibus installations
sudo gitlab-rake gitlab:elastic:index
# Installations from source
bundle exec rake gitlab:elastic:index
```
1. For very big GitLab instances we recommend following [Add GitLab's data to the Elasticsearch index](../integration/elasticsearch.md#indexing-large-instances).
## Things went south? Revert to previous version (11.1)
### 1. Revert the code to the previous version
......
......@@ -23,6 +23,14 @@ module Elastic
indexes :noteable_id, type: :integer, index: :not_analyzed
end
def self.inherited(subclass)
super
subclass.__elasticsearch__.index_name = self.index_name
subclass.__elasticsearch__.document_type = self.document_type
subclass.__elasticsearch__.instance_variable_set(:@mapping, self.mapping.dup)
end
def as_indexed_json(options = {})
data = {}
......
---
title: 'Elasticsearch: Fix a bug causing some types of note to miss being indexed'
merge_request: 6736
author:
type: fixed
......@@ -70,6 +70,14 @@ describe Note, :elastic do
create :note, :system, project: project, noteable: issue
end
it 'uses same index for Note subclasses' do
Note.subclasses.each do |note_class|
expect(note_class.index_name).to eq(Note.index_name)
expect(note_class.document_type).to eq(Note.document_type)
expect(note_class.mappings.to_hash).to eq(Note.mappings.to_hash)
end
end
context 'notes to confidential issues' do
it "does not find note" do
issue = create :issue, :confidential
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment