ios - Adding Objectify index to existing property and existing entity? -
i storing entity using objectify , add index 1 of properties in order run query.
the entity arrives ios client connected via google cloud endpoints. sets property in objective-c class generated servicegenerator
.
so have tried adding @index
annotation property in eclipse , uploading project again appcfg
. however, when inspect datastore in google developers console still says "no indexes serving" , if create new entities , run objectify queries on (now indexed) property still 0 items back.
so exact steps have go through in order add index existing property existing entity defined objectify annotations in eclipse project?
this q&a suggests should straightforward, reason (apparently) not. perhaps complication arises involvement of google cloud endpoints , objective-c client.
update here relevant code snippets, requested:
the property defined follows:
@entity @cache public class someentity { @id public string someid; @index string someproperty }
the ios client sets the property follows (relying on objective-c classes produced servicegenerator
):
someentity.someproperty = @"somestring";
the server receives , saves entity follows:
@apimethod public addentityresponse addentity(addentityrequest request, httpservletrequest httpservletrequest) throws servletexception { someentity someentity = request.someentity; someentity.someid = uuid.randomuuid().tostring(); ofy().save().entity(someentity).now(); // ... }
when server runs following query receives 0 items back, although entity given property value exists (is e.g. visible in datastore viewer):
ofy().load().type(someentity.class).filter("someproperty", "somestring").list();
in order add indexes existing entities have perform these simple steps:
annotate properties @index
save existing entity
the reason point 2 because annotating entity not enough because in datastore
data unaffected. have explicitly re-save existing entity force datastore
create index(es) newly annotated properties.
the same applies when removing indexes. must re-save changes take effect.
edit
from code snippet can see query not quite right. invoking query
method on object returned type(...)
implements loadtype
interface neither of 2 interfaces extended [loadtype][1]
(namely loadids
, query
define method! assume haven't created own wrapper code looks standard objectify, i'm not sure how code compiling or not blowing @ runtime.
anyway fix, since looks want filter specified predicate, change query look:
ofy().load().type(someentity.class).filter("someproperty", "somestring").list();
Comments
Post a Comment