Lens 4 Filter does not work

I am trying to do a simple JUnit test to execute a query like this:

Resource result = ofy().load().type(Resource.class).filter("raw =", "/Bob/-/userId/-/").first().get(); if (result != null){ System.out.println("Resulting Resource raw =" + result.getRaw()); } 

The query above results for null , however, when I execute the query using id (which is a long type), I get the result. When I persisted in essence, I try to query I registered @Id and the value is 1 , so I executed the query using id to check:

 Resource result = ofy().load().type(Resource.class).filter("id =", 1).first().get(); if (result != null){ System.out.println("Resulting Resource raw =" + result.getRaw()); } 

As a result, result.getRaw() has /Bob/-/userId/-/ , which is really strange, should my result not be null from my first request?

+4
source share
1 answer

Check if you have @Index in this field. If you try to select by a field that does not have an index, you will get zero, even if it is. In several fields, you will definitely need an index for all of them.

* An index of more than one field will be placed in datastore-indexes.xml https://cloud.google.com/appengine/docs/java/config/indexconfig

+10
source

Source: https://habr.com/ru/post/1439528/


All Articles