An efficient way to query all records where the field is not zero in objectification

I want to efficiently query an indexed field to retrieve all records where the indexed field is not null (present in the index). The request field contains Ref<T>for another object, if that matters.

What I can do is search for inequality, for example .filter/.filterKey("fieldname >=", "a"), where a is the smallest ASCII I want to capture.

But is it effective? Or can I somehow perform an equality search that returns all the records that are in the index?

-

Here's what my data looks like: I want to filter out all records where the overlay column has a key, and omit those where the field is not set. I would like to use an equality filter if possible, so I don't need a composite index (since I am filtering other fields at the same time).

snapshot of data

-

I can use this for testing != null

.filter("user >", "\uFFFD");

and this is for verification == null

.filter("user <", "\uFFFD");

I think that is not how it should be done. Is there a way to solve this problem using equality instead of inequality?

+4
source share
2 answers

If you want to query objects that have a null value for the indexed field:

ofy().load().type(Thing.class).filter("fieldname !=", null)

, . GAE != ( > <), .

" null", , @OnSave. "true", (.. @Index(IfTrue.class))

+7

- String, , "!= null", :

ofy().load().type(Thing.class).filter("fieldname >=", "");

, > 0, ..

0

All Articles