gpt4 book ai didi

java - 数据存储和index.yaml : no matching index found

转载 作者:行者123 更新时间:2023-12-01 14:10:39 26 4
gpt4 key购买 nike

我有一个在数据存储上执行查询的肥皂服务:

private final String KEY_NAME = "keyName";
private final String KEY_TYPE = "storedData";
private final String ENTITY_TYPE = "record";
private final String TEMP_ROW = "temperatura";
private final String HUM_ROW = "umidita";
private final String DATE_ROW = "date";
private DatastoreService dataStore;
private Key dataKey = KeyFactory.createKey(KEY_TYPE, KEY_NAME);
private final Query query = new Query(ENTITY_TYPE, dataKey).addSort(DATE_ROW,
Query.SortDirection.ASCENDING);

@WebMethod
public int sendData(String temperatura, String umidita) {
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyy HH:mm:ss");
Date date = new Date();

Entity record = new Entity(ENTITY_TYPE, dataKey);
record.setProperty(TEMP_ROW, temperatura);
record.setProperty(HUM_ROW, umidita);
record.setProperty(DATE_ROW, date);
dataStore = DatastoreServiceFactory.getDatastoreService();
dataStore.put(record);
return 1;
}

我已经写了这个index.yaml

indexes:
- kind: Record
ancestor: yes
properties:
- name: temperatura
- name: umidita
- name: data
direction: asc

但是当我尝试执行该查询时出现此错误:

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
<datastore-index kind="Record" ancestor="true" source="manual">
<property name="date" direction="asc"/>
</datastore-index>

index.yaml 与查询不匹配有什么问题?

最佳答案

您定义的索引使用 3 个属性。您的查询仅使用一个索引,或者您将查询更改为使用索引中定义的 3 个属性,或者您定义要在模型声明中建立索引的日期字段。

关于java - 数据存储和index.yaml : no matching index found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18550748/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com