我有一些实体,我希望对其进行祖先查询并通过“>”运算符过滤参数。有问题的实体继承了另一个对象(我认为这不重要)。以下是我的实体类:
@Indexed
public class ValidatedObject {
public Long timeCreated=System.currentTimeMillis();
public Long timeUpdated=System.currentTimeMillis();
public Long getTimeUpdated() {
return timeUpdated;
}
public void setTimeUpdated(Long timeUpdated) {
this.timeUpdated = timeUpdated;
}
public Boolean validated=false;
@Unindexed
public String validatedID;
@Unindexed
private Long validatedTime;
@Unindexed
private String creatorID;
public Long getTimeCreated() {
return timeCreated;
}
public void setTimeCreated(Long timeCreated) {
this.timeCreated = timeCreated;
}
public boolean isValidated() {
return validated;
}
public void setValidated(boolean validated) {
this.validated = validated;
}
public String getValidatedID() {
return validatedID;
}
public void setValidatedID(String validatedID) {
this.validatedID = validatedID;
}
public Long getValidatedTime() {
return validatedTime;
}
public void setValidatedTime(Long validatedTime) {
this.validatedTime = validatedTime;
}
public String getCreatorID() {
return creatorID;
}
public void setCreatorID(String creatorID) {
this.creatorID = creatorID;
}
}
@Cached
@Entity
public class PersonnelInfo extends ValidatedObject{
@Id
public String keyName;
@Parent Key<Department> department;
private Long fdID;
@Unindexed
private String userKeyName;
private String firstName;
private String lastName;
@Unindexed
private String address,city,county,state;
@Unindexed
private String cellPhone,homePhone,otherPhone;
public PersonnelInfo(){
}
public PersonnelInfo(String email){
keyName=email;
}
@Override
public Long getTimeUpdated() {
return timeUpdated;
}
@Override
public void setTimeUpdated(Long time) {
timeUpdated=time;
}
}
我的查询代码如下:
Query<PersonnelInfo> q = ofy.query(PersonnelInfo.class).ancestor(tmp).filter("timeUpdated >", lastSync);
我每次都收到“找不到匹配的索引”错误。没有过滤器,查询工作正常。一些实体缺少“timeUpdated”字段,因为我更改了架构。有些实体是在架构更改后使用 timeUpdated 值创建的,并且它们不会被返回。我也可以像这样在数据存储查看器上执行 GQL 查询:
选择 * where FROM PersonnelInfo timeUpdated > 0
并且我返回了实体,这让我相信索引已创建。我在这里做错了什么?任何帮助,将不胜感激!