在Google数据存储区查询中多次选择引发ApiError:Precondition节点中的失败错误 [英] Multiple select in google datastore query throwing ApiError: Precondition Failed error in node

查看:145
本文介绍了在Google数据存储区查询中多次选择引发ApiError:Precondition节点中的失败错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下查询从Google Datastore中检索一些实体:

  var query = datastore.createQuery(namespace,tableName); query.select(['displayName','username']); datastore.getEntitySet(query,function(err,data){if(err){res.status(500).end();} else {res.send (data);}});  

如果我只选择一个属性,即

query.select('username');



但是多选择其投掷412'Precondition Failed'错误。我的实体如下所示:
实体属性

解决方案

您需要创建多属性索引才能使用多属性查询。



因为您没有使用App Engine,所以需要手动创建这些索引。



我有一个教程 。 >下面是步骤:


  1. 安装Java 7 Runtime(或更高版本) http://java.com/


  2. 创建一个名为WEB-INF的文件夹

  3. 在该文件夹中,您ed三个文件:


  4. datastore-indexes.xml文件,您需要定义您的多属性索引。 查看文档

  5. 安装 gcd工具

  6. 最后,运行gcd工具(位于WEB-INF文件夹之上的一个目录)


    • Linux / Mac path / to / gcd.sh updateindexes --auth_mode = oauth2。

    • Windows 路径/ to / gcd.cmd updateindexes --auth_mode = oauth2。


      几分钟后,应该创建索引。 / p>

      I'm using following query to retrieve some entities from google Datastore:

      var query  = datastore.createQuery(namespace,tableName);
      query.select(['displayName','username']);
      datastore.getEntitySet(query,function(err,data){
      	if(err){
      		  res.status(500).end();
      	  }
      	  else{
      		  res.send(data);
      	  }
      	});

      The above code works fine if I select only one property i.e.

      query.select('username');

      But with multiple select its throwing 412 'Precondition Failed' error. my entity looks like the following: Entity properties

      解决方案

      You need to create a multi-property index in order to use multi-property queries.

      Because you are not using App Engine, these indexes need to be manually created.

      I have a tutorial here that covers this.

      Here are the steps:

      1. Install Java 7 Runtime (or later version) http://java.com/
        • I recommend using Cloud Shell which has Java already installed and configured
      2. Create a folder called WEB-INF
      3. Inside that folder, you need three files:
      4. In the datastore-indexes.xml file, you need to define your multi-property indexes. Follow the documentation.
      5. Install the gcd tool
      6. Finally, run the gcd tool (one directory above the WEB-INF folder)
        • Linux/Mac path/to/gcd.sh updateindexes --auth_mode=oauth2 .
        • Windows path/to/gcd.cmd updateindexes --auth_mode=oauth2 .

      After a few minutes, your indexes should be created.

      这篇关于在Google数据存储区查询中多次选择引发ApiError:Precondition节点中的失败错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆