1

I have a problem that I need to filter query result with Objectify. Typically here is what the String @Key field on stored entities would look like:

  • uid:jamesm:points
  • uid:jsmith:points
  • uid:jax:points
  • uid:ken:points

Now I want to do a query filter like this for the @Key field:

uid:j*:points

Where, I am expecting to get the first three (3) entities listed above. Is this possible with Objectify?

quarks
  • 33,478
  • 73
  • 290
  • 513
  • are you looking for a LIKE query ? http://code.google.com/p/objectify-appengine/wiki/FrequentlyAskedQuestions#How_do_I_do_a_like_query_(LIKE_"foo%") , maybe something similar to this 1 `String start = "uid:j"; ... = ofy.query(MyEntity.class).filter("field >=", start).filter("field <", start + "\uFFFD:points");` – Daniel Aug 28 '12 at 07:36

1 Answers1

2

As described before, you can do this, but only if you compare start of the string: uid:j*

ofy.query(EntityClass.class).filter("property >=", "uid:j")
                            .filter("property <", "uid:j" + "\ufffd");
Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • You mean this will not work: ofy.query(MyEntity.class).filter("field >=", start).filter("field <", start + "\uFFFD:points"); ? – quarks Aug 28 '12 at 15:46