我如何通过NodeJs在谷歌云中设置数据存储区索引configuration?
我试图在我的数据存储上运行GQL查询。 像这样的东西:
SELECT * FROM products WHERE model = @model AND date >= @date
但有这样的错误:
You need an index to execute this query.
在谷歌API文档中,我没有发现关于nodejs的索引。 我如何设置这个索引?
不幸的是截至今天, gcd
工具不支持使用JSON接口(如Node.js或Ruby)的语言自动生成索引。
解决方法是在<your-dataset-directory>/WEB-INF/datastore-indexes.xml
手动定义索引
<?xml version="1.0" encoding="utf-8"?> <datastore-indexes autoGenerate="true"> <datastore-index kind="product" ancestor="false"> <property name="model" direction="asc" /> <property name="date" direction="asc" /> </datastore-index> </datastore-indexes>
有关更多详细信息,请参阅数据存储区文档的索引configuration部分。