我有一个对数据存储执行查询的肥皂服务:
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 有什么问题?