我如何通过NodeJ在谷歌云中设置数据存储索引配置?

时间:2022-03-08 20:00:27

I'm trying to run GQL query on my datastore. Something like this:

我正在尝试在我的数据存储区上运行GQL查询。像这样的东西:

SELECT * FROM products WHERE model = @model AND date >= @date

But there's error like:

但是有一个错误:

You need an index to execute this query.

In google api documentation i found nothing about indexes for nodejs. How i can set this indexes?

在google api文档中,我没有发现nodejs的索引。我怎么设置这个索引?

1 个解决方案

#1


2  

Unfortunatly as of today the gcd tool doesn't support automatic index generation for languages using the JSON interface (like Node.js or Ruby).

不幸的是,到目前为止,gcd工具不支持使用JSON接口(如Node.js或Ruby)自动生成语言索引。

A workaround is the manually define your index in <your-dataset-directory>/WEB-INF/datastore-indexes.xml

解决方法是在 /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>

See the Index Configuration section of the datastore documentation for more details.

有关更多详细信息,请参阅数据存储区文档的“索引配置”部分。

#1


2  

Unfortunatly as of today the gcd tool doesn't support automatic index generation for languages using the JSON interface (like Node.js or Ruby).

不幸的是,到目前为止,gcd工具不支持使用JSON接口(如Node.js或Ruby)自动生成语言索引。

A workaround is the manually define your index in <your-dataset-directory>/WEB-INF/datastore-indexes.xml

解决方法是在 /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>

See the Index Configuration section of the datastore documentation for more details.

有关更多详细信息,请参阅数据存储区文档的“索引配置”部分。