@@ -289,7 +289,7 @@ public FirebaseApp getApp() {
289
289
}
290
290
291
291
/**
292
- * Configures Indexing for local query execution. Any previous index configuration is overridden.
292
+ * Configures indexing for local query execution. Any previous index configuration is overridden.
293
293
* The Task resolves once the index configuration has been persisted.
294
294
*
295
295
* <p>The index entries themselves are created asynchronously. You can continue to use queries
@@ -307,10 +307,14 @@ public FirebaseApp getApp() {
307
307
Task <Void > setIndexConfiguration (String json ) {
308
308
ensureClientConfigured ();
309
309
310
+ if (!settings .isPersistenceEnabled ()) {
311
+ throw new IllegalStateException ("Cannot enable indexes when persistence is disabled" );
312
+ }
313
+
310
314
// Preconditions.checkState(BuildConfig.ENABLE_INDEXING, "Indexing support is not yet
311
315
// available.");
312
316
313
- List <FieldIndex > parsedIndices = new ArrayList <>();
317
+ List <FieldIndex > parsedIndexes = new ArrayList <>();
314
318
315
319
// See https://firebase.google.com/docs/reference/firestore/indexes/#json_format for the
316
320
// format of the index definition. Unlike the backend, the SDK does not distinguish between
@@ -320,9 +324,9 @@ Task<Void> setIndexConfiguration(String json) {
320
324
JSONObject jsonObject = new JSONObject (json );
321
325
322
326
if (jsonObject .has ("indexes" )) {
323
- JSONArray indices = jsonObject .getJSONArray ("indexes" );
324
- for (int i = 0 ; i < indices .length (); ++i ) {
325
- JSONObject definition = indices .getJSONObject (i );
327
+ JSONArray indexes = jsonObject .getJSONArray ("indexes" );
328
+ for (int i = 0 ; i < indexes .length (); ++i ) {
329
+ JSONObject definition = indexes .getJSONObject (i );
326
330
String collectionGroup = definition .getString ("collectionGroup" );
327
331
List <FieldIndex .Segment > segments = new ArrayList <>();
328
332
@@ -340,7 +344,7 @@ Task<Void> setIndexConfiguration(String json) {
340
344
}
341
345
}
342
346
343
- parsedIndices .add (
347
+ parsedIndexes .add (
344
348
FieldIndex .create (
345
349
FieldIndex .UNKNOWN_ID , collectionGroup , segments , FieldIndex .INITIAL_STATE ));
346
350
}
@@ -349,7 +353,7 @@ Task<Void> setIndexConfiguration(String json) {
349
353
throw new IllegalArgumentException ("Failed to parse index configuration" , e );
350
354
}
351
355
352
- return client .configureFieldIndexes (parsedIndices );
356
+ return client .configureFieldIndexes (parsedIndexes );
353
357
}
354
358
355
359
/**
0 commit comments