If I don't use a filter, I get results. If I use a filter (this record definitely exists), I don't get any results. It might be the lack of an index defined for that property, but, as I understand it, simple indices should automatically be created in the development server (and an index.yaml file created and populated with it). This is not happening.
query = datastore.NewQuery("UserAccount").Filter("email =", "test@example.com")
ua := UserAccount{}
t := query.Run(ctx)
for ; ; {
if _, err = t.Next(&ua); err == nil {
log.Debugf(ctx, "Current: %s", ua)
} else if err == datastore.Done {
break
} else {
panic(err)
}
}
When the development server terminates, it states that it's "saving search indexes":
INFO 2016-08-08 05:09:52,894 api_server.py:651] Saving search indexes
However, since an "index.yaml" file doesn't appear, I'm assuming that no indices needed to be created, which means that my query must not've had the desired effect?
What am I missing?
Edit:
Note that the record was previously created and the application stopped and started many times since. I sincerely doubt this is a eventual-consistency thing.
Edit 2:
For the purpose of testing, I've created the following model with the following code. They both exhibit the same behavior as my original model and code.
Definition:
type TestEntity struct {
Email string
}
Code:
log.Debugf(ctx, "Putting.")
email := "anothertest@a.b"
te := &TestEntity{
Email: email,
}
k := datastore.NewKey(ctx, "TestEntity", "123", 0, nil)
_, err = datastore.Put(ctx, k, te)
if err != nil {
panic(err)
}
log.Debugf(ctx, "Waiting.")
time.Sleep(1 * time.Second)
query := datastore.NewQuery("TestEntity")
var results []TestEntity
_, err = query.GetAll(ctx, &results)
log.Debugf(ctx, "GetAll: %s", results)
log.Debugf(ctx, "Running query.")
query = datastore.NewQuery("TestEntity").Filter("email =", email)
te = &TestEntity{}
t := query.Run(ctx)
for ; ; {
if _, err = t.Next(te); err == nil {
log.Debugf(ctx, "Found: [%s]", te.Email)
} else if err == datastore.Done {
log.Debugf(ctx, "Done.")
break
} else {
panic(err)
}
}
Results:
2016/08/09 02:11:36 DEBUG: Putting.
2016/08/09 02:11:36 DEBUG: Waiting.
2016/08/09 02:11:37 DEBUG: GetAll: [{anothertest@a.b}]
2016/08/09 02:11:37 DEBUG: Running query.
2016/08/09 02:11:37 DEBUG: Done.
Screenshot of Viewer: