2017-12-07 14 views
0

내 모델의 특성이 있습니다 또한필터 개체가

Key emailKey = KeyFactory.createKey("email", email); 
Filter filter = new 
     FilterPredicate(Entity.KEY_RESERVED_PROPERTY, FilterOperator.EQUAL, emailKey); 

result = ObjectifyService.ofy().load().type(User.class) 
     .filter(filter); 

:

@Id 
@Index 
public String email; 

그리고 필터

검색 할 email 변수를 사용하여,이 필터가 나는 이것을 시도한다 :

result = ObjectifyService.ofy().load().type(User.class) 
     .filterKey("__key__", email); 

그러나 그들 중 어느 것도 작동하지 않는다?

답변

0

키 객체와 키 객체를 비교해야 할 때 객체를 문자열과 비교합니다.

__key__은 Key 유형의 특수 속성입니다. 이것은 문자열이 아닙니다. 이 필터를 실행하려면 이메일을 제외한 .filterKey("__key__", email)을 입력해야합니다. 여기서 전체 키를 입력해야합니다.

여기에서 키 필터 섹션을 참조하십시오.

https://cloud.google.com/datastore/docs/concepts/queries#filters