Java 根据数组项获取集合,给出;失败的前提条件:查询需要索引;

Java 根据数组项获取集合,给出;失败的前提条件:查询需要索引;,java,android,firebase,google-cloud-firestore,Java,Android,Firebase,Google Cloud Firestore,我试图找出所有有“数学”标签的问题,但不是成功,而是失败的听众 db.collection("questionCollection") .orderBy("questionID", Query.Direction.DESCENDING) .whereArrayContains("tags","maths") .limit(3) .get()

我试图找出所有有“数学”标签的问题,但不是成功,而是失败的听众

db.collection("questionCollection")
                .orderBy("questionID", Query.Direction.DESCENDING)
                .whereArrayContains("tags","maths")
                .limit(3)
                .get()
                .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                    @Override
                    public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                        if (queryDocumentSnapshots.isEmpty()) {
                            Log.d(TAG, "onSuccess: LIST EMPTY");
                            return;
                        } else {
                            // Convert the whole Query Snapshot to a list
                            // of objects directly! No need to fetch each
                            // document.
                            questionList = queryDocumentSnapshots.toObjects(QuestionBO.class);

                            if (questionList != null && questionList.size() > 0)
                                mAdapter.updateQuestions(questionList);
                        }
                    }
                }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                e.printStackTrace();
                Toast.makeText(mContext,"Failed",Toast.LENGTH_LONG).show();
            }
        });

只需单击该错误消息中提供给您的链接。它会将您带到控制台,要求您创建满足您试图执行的查询的索引。

那么,打印的异常是什么?您得到的异常是什么?我们需要有关该问题的更多信息。你得到了什么样的异常?我已经更新了异常。这个查询需要一个索引。我想异常已经回答了你的问题,不是吗?
FAILED_PRECONDITION: The query requires an index. You can create it here: https://console.firebase.google.com/project/testingproject-384af/database/firestore/indexes?create_index=EhJxd