Small indexing fixes
@@ -289,7 +289,7 @@ public class FirebaseFirestore {
}
/**
- * Configures Indexing for local query execution. Any previous index configuration is overridden.
+ * Configures indexing for local query execution. Any previous index configuration is overridden.
* The Task resolves once the index configuration has been persisted.
*
* <p>The index entries themselves are created asynchronously. You can continue to use queries
@@ -307,10 +307,14 @@ public class FirebaseFirestore {
Task<Void> setIndexConfiguration(String json) {
ensureClientConfigured();
+ if (!settings.isPersistenceEnabled()) {
+ throw new IllegalStateException("Cannot enable indexes when persistence is disabled");
+ }
+
// Preconditions.checkState(BuildConfig.ENABLE_INDEXING, "Indexing support is not yet
// available.");
- List<FieldIndex> parsedIndices = new ArrayList<>();
+ List<FieldIndex> parsedIndexes = new ArrayList<>();
// See https://firebase.google.com/docs/reference/firestore/indexes/#json_format for the
// format of the index definition. Unlike the backend, the SDK does not distinguish between
@@ -320,9 +324,9 @@ public class FirebaseFirestore {
JSONObject jsonObject = new JSONObject(json);
if (jsonObject.has("indexes")) {
- JSONArray indices = jsonObject.getJSONArray("indexes");
- for (int i = 0; i < indices.length(); ++i) {
- JSONObject definition = indices.getJSONObject(i);
+ JSONArray indexes = jsonObject.getJSONArray("indexes");
+ for (int i = 0; i < indexes.length(); ++i) {
+ JSONObject definition = indexes.getJSONObject(i);
String collectionGroup = definition.getString("collectionGroup");
List<FieldIndex.Segment> segments = new ArrayList<>();
@@ -340,7 +344,7 @@ public class FirebaseFirestore {
}
}
- parsedIndices.add(
+ parsedIndexes.add(
FieldIndex.create(
FieldIndex.UNKNOWN_ID, collectionGroup, segments, FieldIndex.INITIAL_STATE));
}
@@ -349,7 +353,7 @@ public class FirebaseFirestore {
throw new IllegalArgumentException("Failed to parse index configuration", e);
}
- return client.configureFieldIndexes(parsedIndices);
+ return client.configureFieldIndexes(parsedIndexes);
}
/**
