Skip to content

Elasticsearch: when index is absent, auto created index does not honor setting and mapping

Summary

When no index exists yet, yet we turned on "Elasticsearch Indexing", any index call would automatically create an index. However that index does not honor GitLab's setting and mappings, making that index useless.

Steps to reproduce

Without creating an index, trigger a document update (index).

What is the current bug behavior?

Subsequent searches would fail

What is the expected correct behavior?

Give an error if index has not been set up yet.

Possible fixes

One way to fix this is to override the default create_index! method. We can override inside ApplicationClassProxy. We can move the logic of Gitlab::Elastic::Helper.create_empty_index as the create_index! method, and I think elasticsearch-rails would then use our code to create the index.

Set the cluster setting to "action.auto_create_index": "false", so the Elasticsearch server would not create an index if it is absent.

Edited by Mark Chao