Thank you for your help.
Environment
GAE 1.9.25
objectify: 5.1.9
I am currently using GAE to create a web application, but I cannot get the Cursor in the following conditions and it becomes null.
If there is at least one tagList element in keywords, I would like to get it.
Query<Hoge>query=ofy().load().type(Hoge.class).limit(limit);
query=query.filter("tagList in", keywords);
QueryResultIterator<Hoge>iterator=query.iterator();
List<Hoge>result=new ArrayList<Hoge>(query.count());
while(iterator.hasNext()){
Hoge hoge=iterator.next();
result.add(hoge);
}
log.info("cursor="+iterator.getCursor());
If you execute the above code, getCursor will be null.
If keywords.length == 1, it works fine, but this behavior occurs when one or more elements are present.
Why does the cursor become null?
Thank you for your cooperation.
This question is a long time ago, so it may have been solved...
Conditions like hoge IN(a,b,c)
are basically not searchable due to the way the datastore index works.
GAE/Java supports INfilter, which appears to be merging results within the SDK library running three queries: hoge=a
, hoge=b
, hoge=c
.
Therefore, if you use IN, you cannot return the cursor.
If the IN condition is one, it will be a query of hoge=a
, so the cursor will be returned.
Note:
https://cloud.google.com/appengine/docs/java/datastore/query-cursors
Because the NOT_EQUAL and IN operators are implemented with multiple queries, queries that use them do not support cursors, nor do composite queries constructed with the CompositeFilterOperator.or method.
© 2024 OneMinuteCode. All rights reserved.