Commit 9e12d820 authored by Valery Sizov's avatar Valery Sizov

Merge branch 'es_remove_items' into 'master'

ES: Removing repository and wiki index after removing project

https://gitlab.com/gitlab-org/gitlab-ee/issues/299

https://gitlab.com/gitlab-org/gitlab-ee/issues/209


cc @jnijhof @jacobvosmaer 

@axil I've touched documentation here. Please take a look. 

See merge request !205
parents fa85d400 04bdf625
Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Improve weight filter for issues
- [Elastic] Add elastic checker to gitlab:check
- [Elastic] Added UPDATE_INDEX option to rake task
- [Elasticsearch] Removing repository and wiki index after removing project
v 8.5.1
- Fix adding pages domain to projects in groups
......
......@@ -6,16 +6,43 @@ class ElasticIndexerWorker
Client = Elasticsearch::Client.new(host: Gitlab.config.elasticsearch.host,
port: Gitlab.config.elasticsearch.port)
def perform(operation, klass, record_id, options = {})
cklass = klass.constantize
def perform(operation, class_name, record_id, options = {})
klass = class_name.constantize
case operation.to_s
when /index|update/
record = cklass.find(record_id)
record = klass.find(record_id)
record.__elasticsearch__.client = Client
record.__elasticsearch__.__send__ "#{operation}_document"
when /delete/
Client.delete index: cklass.index_name, type: cklass.document_type, id: record_id
Client.delete index: klass.index_name, type: klass.document_type, id: record_id
clear_project_indexes(record_id) if klass == Project
end
end
def clear_project_indexes(record_id)
# Remove repository index
Client.delete_by_query({
index: Repository.__elasticsearch__.index_name,
body: {
query: {
or: [
{ term: { "commit.rid" => record_id } },
{ term: { "blob.rid" => record_id } }
]
}
}
})
# Remove wiki index
Client.delete_by_query({
index: ProjectWiki.__elasticsearch__.index_name,
body: {
query: {
term: { "blob.rid" => "wiki_#{record_id}" }
}
}
})
end
end
......@@ -31,7 +31,7 @@ is installed or on a separate server.
These are the minimum requirements needed for Elasticsearch to work:
- GitLab 8.4+
- Elasticsearch 2.0+
- Elasticsearch 2.0+ (with [Delete By Query Plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html) installed)
## Install Elasticsearch
......
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