Python App Engine 1.8.4将文档放入搜索索引时引发AttributeError

Python App Engine 1.8.4将文档放入搜索索引时引发AttributeError,python,google-app-engine,gae-search,Python,Google App Engine,Gae Search,我一直在使用AppEngineAPI的1.8.1版本,因为在更高版本中远程API存在已知问题。在尝试最新的1.8.4时,我遇到了一个错误,代码在1.8.1中运行良好,但现在尝试将文档添加到搜索索引时失败: Traceback (most recent call last): File "~/tools/devappserver2/api_server.py", 62, in _handle_POST api_response = _execute_request(request)

我一直在使用AppEngineAPI的1.8.1版本,因为在更高版本中远程API存在已知问题。在尝试最新的1.8.4时,我遇到了一个错误,代码在1.8.1中运行良好,但现在尝试将文档添加到搜索索引时失败:

Traceback (most recent call last):
   File "~/tools/devappserver2/api_server.py", 
62, in _handle_POST
    api_response = _execute_request(request).Encode()
  File "~/tools/devappserver2/api_server.py", line 1
23, in _execute_request
    make_request()
  File "~/tools/devappserver2/api_server.py", line 1
15, in make_request
    request_id)
  File "~/google/appengine/api/apiproxy_stub.py", line 130, in MakeSy
ncCall
    method(request, response)
  File "~/google/appengine/api/search/simple_search_stub.py", line 65
4, in _Dynamic_IndexDocument
    index.IndexDocuments(params.document_list(), response)
  File "~/google/appengine/api/search/simple_search_stub.py", line 40
4, in IndexDocuments
    self._inverted_index.AddDocument(doc_id, document)
  File "~/google/appengine/api/search/simple_search_stub.py", line 30
3, in AddDocument
    self._AddFieldType(field.name(), field.value().type())
  File "~/google/appengine/api/search/simple_search_stub.py", line 28
9, in _AddFieldType
    self._schema.AddFieldType(name, field_type)
AttributeError: 'dict' object has no attribute 'AddFieldType'

ERROR    2013-09-14 22:31:45,132 webapp2.py:1552] AttributeError("'dict' object has no attribute 'Ad
dFieldType'",)
Traceback (most recent call last):
  File "~/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "~/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "~/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispat
cher
    return route.handler_adapter(request, response)
  File "~/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "~/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "~/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "~/docroot/update.py", line 49, in get
    booking.add_to_search_index()
  File "~/docroot/booking.py", line 94, in add_to_search_index
    index.put(booking_full_text_document)
  File "~/google/appengine/api/search/search.py", line 2506, in put
    response)
  File "~/google/appengine/api/apiproxy_stub_map.py", line 94, in Mak
eSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "~/google/appengine/api/apiproxy_stub_map.py", line 328, in Ma
keSyncCall
    rpc.CheckSuccess()
  File "~/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitIm
pl
    self.request, self.response)
  File "~/google/appengine/ext/remote_api/remote_api_stub.py", line 2
00, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "~/google/appengine/ext/remote_api/remote_api_stub.py", line 2
34, in _MakeRealSyncCall
    raise pickle.loads(response_pb.exception())
RuntimeError: AttributeError("'dict' object has no attribute 'AddFieldType'",)
INFO     2013-09-14 22:31:45,145 module.py:593] default: "GET /update/somekey/someparamter/value HTTP/1.1" 500 2
691
本规范负责人:

from google.appengine.ext import ndb
from google.appengine.api import search
import logging

class Booking(ndb.Model):

    timestamp = ndb.DateTimeProperty(auto_now_add=True)
    last_modified = ndb.DateTimeProperty(auto_now=True)

    field1 = ndb.StringProperty()
    field2 = ndb.StringProperty()
    #etc...

    def add_to_search_index(self):

        list_of_full_text_fields = [
            'field1',
            'field2',
        ]

        full_text_data = []

        for field in list_of_full_text_fields:

            full_text_data.append(unicode(getattr(self, field)))

        full_text_data = ' '.join(full_text_data)

        full_text_document = search.Document(

        doc_id = self.key.urlsafe(),
        fields=[
            search.TextField(
                name='f',
                value=full_text_data
            ),
           ]
        )

        try:
            index = search.Index(name="fullText")
            index.put(full_text_document)
        except search.Error:
            logging.exception('Put failed')

可能是这些版本中的API更改吗

版本1.8.3-2013年8月6日 发布了对搜索API文档的重大重写。请参阅:

或者是错误修正

版本1.8.4-2013年9月9日 修复了与搜索API中的表达式关联的unicode问题。对包含unicode字符的文档使用片段字段进行搜索失败