Fix account and group query with Elasticsearch 6

When querying against Elasticsearch 6, gerrit uses the following
URLs:

  http://elasticsearch:9200/gerrit_accounts_0010/accounts/_search
  http://elasticsearch:9200/gerrit_groups_0007/groups/_search

whereas it should use:

  http://elasticsearch:9200/gerrit_accounts_0010/_doc/_search
  http://elasticsearch:9200/gerrit_groups_0007/_doc/_search

The type is properly resolved through the index adapter, so use that
to build the ElasticQuerySource instead of using hard coded constants
for both accounts and groups indexes.

Bug: Issue 10591
Change-Id: I90cd74da9246f56bc9b2ef8464587ab04152876b
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
diff --git a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
index 1b69b6d..d0b70ae 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticAccountIndex.java
@@ -93,8 +93,7 @@
   public DataSource<AccountState> getSource(Predicate<AccountState> p, QueryOptions opts)
       throws QueryParseException {
     JsonArray sortArray = getSortArray(AccountField.ID.getName());
-    return new ElasticQuerySource(
-        p, opts.filterFields(IndexUtils::accountFields), ACCOUNTS, sortArray);
+    return new ElasticQuerySource(p, opts.filterFields(IndexUtils::accountFields), type, sortArray);
   }
 
   @Override
diff --git a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java b/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
index f694a05..e74f208 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticGroupIndex.java
@@ -91,7 +91,7 @@
   public DataSource<InternalGroup> getSource(Predicate<InternalGroup> p, QueryOptions opts)
       throws QueryParseException {
     JsonArray sortArray = getSortArray(GroupField.UUID.getName());
-    return new ElasticQuerySource(p, opts.filterFields(IndexUtils::groupFields), GROUPS, sortArray);
+    return new ElasticQuerySource(p, opts.filterFields(IndexUtils::groupFields), type, sortArray);
   }
 
   @Override