Add support for secondary index with Elasticsearch

Add support for secondary index on Elasticsearch via the REST API
using the Jest client [1].

Because Elasticsearch uses different version of Lucene we add another
maven_jar's in gerrit-elasticsearch BUCK. Fortunately both versions have
compatible API, this way we are able to compile and run Gerrit.

All tests for changes index passes, but they need to use Lucene's based
account index.

[1] http://www.searchly.com/documentation/developer-api-guide/java-jest/

TODO: Add support for online reindex
TODO: Add support for schema upgrades

Also-By: Janice Agustin <janice.agustin@ericsson.com>
Also-By: Olga Grinberg <olga.grinberg@ericsson.com>
Also-By: Dariusz Luksza <dluksza@collab.net>
Change-Id: I5e4fc08ce34d33c090c9e0bf320de1b17309f774
This commit is contained in:
David Pursehouse
2014-06-24 11:01:28 +09:00
committed by David Pursehouse
parent b4d30002d6
commit 8e72f5301b
24 changed files with 1505 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STA
import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -91,6 +92,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -110,6 +112,8 @@ public class LuceneChangeIndex implements ChangeIndex {
public static final String CHANGES_OPEN = "open";
public static final String CHANGES_CLOSED = "closed";
public static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
"_", " ", ".", " ");
static final String UPDATED_SORT_FIELD =
sortFieldName(ChangeField.UPDATED);
@@ -405,7 +409,7 @@ public class LuceneChangeIndex implements ChangeIndex {
}
}
private Set<String> fields(QueryOptions opts) {
public static Set<String> fields(QueryOptions opts) {
// Ensure we request enough fields to construct a ChangeData. We need both
// change ID and project, which can either come via the Change field or
// separate fields.

View File

@@ -86,7 +86,7 @@ public class LuceneIndexModule extends LifecycleModule {
if (singleVersions == null) {
install(new MultiVersionModule());
} else {
install(new SingleVersionModule());
install(new SingleVersionModule(singleVersions));
}
}
@@ -105,7 +105,13 @@ public class LuceneIndexModule extends LifecycleModule {
}
}
private class SingleVersionModule extends LifecycleModule {
public static class SingleVersionModule extends LifecycleModule {
private final Map<String, Integer> singleVersions;
public SingleVersionModule(Map<String, Integer> singleVersions) {
this.singleVersions = singleVersions;
}
@Override
public void configure() {
listener().to(SingleVersionListener.class);
@@ -116,7 +122,7 @@ public class LuceneIndexModule extends LifecycleModule {
}
@Singleton
static class SingleVersionListener implements LifecycleListener {
private static class SingleVersionListener implements LifecycleListener {
private final Set<String> disabled;
private final Collection<IndexDefinition<?, ?, ?>> defs;
private final Map<String, Integer> singleVersions;