Name Elasticsearch indexes the same way it's done for Lucene
Change index is now named 'changes_0001' instead of 'gerrit'. This will enable to have other indexes like the accounts index and multiple versions to support online reindexing. The only difference is Elasticsearch allows to prefix the index name to allow to have use more than one Gerrit server in the same Elasticsearch server. Prefix 'gerrit1_' would result in a change index named 'gerrit1_changes_0001'. Change-Id: I9d089b6a0ce0e708a59e1f322ea1c011f78ffd31
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.elasticsearch;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.elasticsearch.ElasticChangeIndex.CHANGES_PREFIX;
|
||||
import static com.google.gerrit.elasticsearch.ElasticChangeIndex.CLOSED_CHANGES;
|
||||
import static com.google.gerrit.elasticsearch.ElasticChangeIndex.OPEN_CHANGES;
|
||||
|
||||
@@ -51,6 +52,9 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
private static final Gson gson = new GsonBuilder()
|
||||
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
||||
.create();
|
||||
private static final String INDEX_NAME =
|
||||
String.format("%s%04d", CHANGES_PREFIX,
|
||||
ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
|
||||
private static Node node;
|
||||
private static String port;
|
||||
private static File elasticDir;
|
||||
@@ -112,7 +116,7 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
|
||||
@After
|
||||
public void cleanupIndex() {
|
||||
node.client().admin().indices().prepareDelete("gerrit").execute();
|
||||
node.client().admin().indices().prepareDelete(INDEX_NAME).execute();
|
||||
createIndexes();
|
||||
}
|
||||
|
||||
@@ -135,7 +139,6 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
elasticsearchConfig.setString("index", null, "protocol", "http");
|
||||
elasticsearchConfig.setString("index", null, "hostname", "localhost");
|
||||
elasticsearchConfig.setString("index", null, "port", port);
|
||||
elasticsearchConfig.setString("index", null, "name", "gerrit");
|
||||
elasticsearchConfig.setBoolean("index", "elasticsearch", "test", true);
|
||||
return Guice.createInjector(
|
||||
new InMemoryModule(elasticsearchConfig, notesMigration));
|
||||
@@ -151,7 +154,7 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
node.client()
|
||||
.admin()
|
||||
.indices()
|
||||
.prepareCreate("gerrit")
|
||||
.prepareCreate(INDEX_NAME)
|
||||
.addMapping(OPEN_CHANGES, gson.toJson(openChangesMapping))
|
||||
.addMapping(CLOSED_CHANGES, gson.toJson(closedChangesMapping))
|
||||
.execute()
|
||||
|
Reference in New Issue
Block a user