All of a sudden this morning, I began getting this error in my app,
when doing a search inside of an internal process (searching for
duplicates) and then taking a count() of the results.  It was working
fine before.  I have this same query on a search page as well, and
it's still fine.  The search page does not call count() though.
Perhaps it has something to do with the number of results being
returned, I'll try to instrument to get a apples to apples search
string comparison.   Any ideas on this though?

This is the stack trace:

File "/base/data/home/apps/...", line 196, in approvePost
    if qPosts.count() > 0:
  File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 1353, in count
    return self._get_query().Count(limit=limit)
  File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 960, in Count
    raise _ToDatastoreError(err)
  File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 1637, in _ToDatastoreError
    raise errors[err.application_error](err.error_detail)
NeedIndexError: The built-in indices are not efficient enough for this
query and your data. Please add a composite index for this query.


This is the offending code:

qPosts = datamodel.Post.all().search(search_string).filter("approved =
", True)
if qPosts.count() > 0:


This is the model:

class Post(search.SearchableModel):
    user = db.ReferenceProperty(User, collection_name='posts')
    status_id = db.IntegerProperty(required=True)
    entry = db.TextProperty(required=True)
    entry_title = db.StringProperty(required=True,multiline=True)
    entry_link = db.LinkProperty(required=True)
    approved = db.BooleanProperty(required=True, default=False)
    reject_reason = db.StringListProperty(default=None)
    retweet_status_id = db.IntegerProperty(required=False)
    in_reply_to_status_id = db.IntegerProperty(required=False)
    short_url = db.LinkProperty(required=False)
    hash = db.StringProperty(required=False)
    source = db.StringProperty(required=False)
    view_count = db.IntegerProperty(required=True, default=0)
    reply_count = db.IntegerProperty(required=True, default=0)
    like_count = db.IntegerProperty(required=True, default=0)
    published = db.DateTimeProperty()
    created = db.DateTimeProperty(auto_now_add=True)


I tried adding this index, but was still getting the error:

- kind: Post
  properties:
  - name: __searchable_text_index
  - name: approved


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to