Daniel Müssig
Daniel Müssig

Reputation: 1602

How to filter queries in GQL with Entities created by objectify?

I have the following table called MACObs in the Datastore Viewer:

ID/Name         accessPoint             mac                     obs
id=42310053     xx:xx:xx:xx:xx:xx       yy:yy:yy:yy:yy:yy       302 bytes, SHA-1 = 031688dc48d2e71bc80b1c16016cbb108c5af3e7

So now I thought I can do a GQL query like this:

SELECT * FROM MACObs WHERE accessPoint = 'xx:xx:xx:xx:xx:xx'

But when I run this query, I get only this answer:

No results in Empty namespace.

Maybe its important to say that I create the entities in the backend with objectify.

Upvotes: 0

Views: 349

Answers (1)

Romin
Romin

Reputation: 8816

OK. Here is the documentation from Objectify "Objectify does not index properties by default. You must explicitly define single-property indexes with the @Index annotation."

So try out the following: Add an @Index annotation to your accessPoint attribute.

So your definition will become:

@Entity 
public class MACObs { 
  @Id private Long id; 
  private String mac; 
  @Index private String accessPoint; 
  @Serialize private ArrayList<Long[]> obs; 
  ...
  getter/setter methods
  ...
}

Upvotes: 1

Related Questions