Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 我可以使用flatter在firestore上创建索引吗?_Flutter_Google Cloud Firestore - Fatal编程技术网

Flutter 我可以使用flatter在firestore上创建索引吗?

Flutter 我可以使用flatter在firestore上创建索引吗?,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我使用下面的flatter代码查询firestore,firestore使用字段时间戳订购数据 var results = Firestore.instance.collection('post').orderBy('timestamp').getDocuments().then((value) { var list = value.documents; return list.map((doc) { return doc.documentID; }).toList(); }

我使用下面的flatter代码查询firestore,firestore使用字段时间戳订购数据

var results = Firestore.instance.collection('post').orderBy('timestamp').getDocuments().then((value) {
  var list = value.documents;
  return list.map((doc) {
    return doc.documentID;
  }).toList();
});    
当我运行此代码时,它抛出以下异常,表示需要索引:

W/Firestore(31110):(21.3.0)[Firestore]:侦听查询(app/jqh7fp9xczwyiqre7le/post,其中readAccess数组包含任何[wzkimodx6wyvqdsw3az3xrunm2,PUBLIC]order by-timestamp,name)失败:状态{code=failed\u前提条件,描述=查询需要索引。您可以在此处创建它:

例外情况甚至还包括一个漂亮的链接。打开该链接时,会弹出一个漂亮的UI,使我能够创建索引,只需简单的单击:

问题:尽管上面看起来很简单,但我对此不太满意。我更希望能够从代码中创建索引。在代码中,我正在寻找类似以下内容的内容:

Firestore.instance.collection('post').API-TO-CREATE-INDEX('timestamp');

是否存在?请提供建议。非常感谢。

无法从客户端应用创建索引。您有三个主要选择:

  • 单击您已经看到的链接
  • 使用从命令行部署索引
  • 使用也可以从命令行部署

  • 另请参见。

    无法从客户端应用创建索引。您有三个主要选择:

  • 单击您已经看到的链接
  • 使用从命令行部署索引
  • 使用也可以从命令行部署
  • 另见