I am storing an entity using Objectify and would now like to add an index to one of the properties in order to run a query.
The entity arrives from an iOS client that is connected via Google Cloud Endpoints. It sets the property in the Objective-C class that was generated by ServiceGenerator
.
So what I have tried is adding an @Index
annotation to the property in Eclipse and uploading the project again with appcfg
. However, when I inspect the datastore in Google Developers Console is still says "No indexes serving" and if I create new entities and run Objectify queries on the (now indexed) property is still get zero items back.
So what exact steps do I have to go through in order to add an index to an existing property for an existing entity that is defined with Objectify annotations in an Eclipse project?
This Q&A suggests it should be straightforward, but for some reason it is (apparently) not. Perhaps the complication arises from the involvement of Google Cloud Endpoints and an Objective-C client.
Update Here are some relevant code snippets, as requested:
The property is defined as follows:
@Entity
@Cache
public class SomeEntity {
@Id public String someID;
@Index String someProperty
}
The iOS client sets the the property as follows (relying on Objective-C classes produced by ServiceGenerator
):
someEntity.someProperty = @"someString";
The server receives and saves the entity as 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 the server runs the following query it receives zero items back, although an entity with the given property value exists (is e.g. visible in the datastore viewer):
ofy().load().type(SomeEntity.class).filter("someProperty", "someString").list();