Having created a SearchableModel entity, updating it doesn't seem to
update the full text index - Is that expected behaviour?
A little unit test to explain what I mean:
import sys, os, time
sys.path.append('/usr/local/google_appengine')
sys.path.append('/usr/local/google_appengine/lib/yaml/lib')
import unittest
from google.appengine.api import apiproxy_stub_map
from google.appengine.api import datastore_file_stub
from google.appengine.api import mail_stub
from google.appengine.api import urlfetch_stub
from google.appengine.api import user_service_stub
from google.appengine.ext import db, search
APP_ID = u'test'
AUTH_DOMAIN = '
gmail.com'
LOGGED_IN_USER = '
te...@example.com'
class Searchable(search.SearchableModel):
searchtext = db.TextProperty()
class TestSearch(unittest.TestCase):
def setUp(self):
# Ensure we're in UTC.
os.environ['TZ'] = 'UTC'
time.tzset()
# Start with a fresh api proxy.
apiproxy_stub_map.apiproxy =
apiproxy_stub_map.APIProxyStubMap()
# Use a fresh stub datastore.
stub = datastore_file_stub.DatastoreFileStub(APP_ID, '/dev/
null', '/dev/null')
apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)
# Use a fresh stub UserService.
apiproxy_stub_map.apiproxy.RegisterStub(
'user', user_service_stub.UserServiceStub())
os.environ['AUTH_DOMAIN'] = AUTH_DOMAIN
os.environ['USER_EMAIL'] = LOGGED_IN_USER
# Use a fresh urlfetch stub.
apiproxy_stub_map.apiproxy.RegisterStub(
'urlfetch', urlfetch_stub.URLFetchServiceStub())
# Use a fresh mail stub.
apiproxy_stub_map.apiproxy.RegisterStub(
'mail', mail_stub.MailServiceStub())
def testUpdate(self):
# create an entity
s = Searchable(searchtext='Test Entry One')
s.put()
id = s.key().id()
# make sure we can find it by search
result = Searchable.all().search('one')
self.assertEquals(1, result.count())
# reload the entity directly from the db
s = Searchable.get_by_id(id)
self.assertEquals('Test Entry One', s.searchtext)
# update the search text and re-save it
s.searchtext = 'Test Entry Updated'
s.put()
# shouldn't be any entries with 'one' in them now
result = Searchable.all().search('one')
self.assertEquals(0, result.count())
# should be able to find our updated entry though
result = Searchable.all().search('updated')
self.assertEquals(1, result.count())
if __name__ == '__main__':
unittest.main()