这是什么意思?
Trace:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~montaoproject/refactor.383610131340137947/main.py", line 3222, in post
value=cityID),
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/search/search.py", line 1462, in __init__
Field.__init__(self, name, value)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/search/search.py", line 892, in __init__
self._value = self._CheckValue(value)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/search/search.py", line 1469, in _CheckValue
(value, MIN_NUMBER_VALUE, MAX_NUMBER_VALUE))
ValueError: value, 6463062097788928 must be between -2147483647 and 2147483647
违规行3222是value=cityID
,在我建立索引时的上下文中。
doc = search.Document(doc_id=str(ad.key()), fields=[
search.TextField(name='title', value=ad.title),
search.TextField(name='text', value=ad.text),
search.TextField(name='city', value=ad.city),
search.TextField(name='region', value=ad.region),
search.NumberField(name='cityID',
value=cityID),
search.NumberField(name='regionID',
value=regionID),
search.NumberField(name='category',
value=int(ad.category)),
search.NumberField(name='constant', value=1),
search.TextField(name='adID', value=str(ad.key().id())),
search.TextField(name='name', value=ad.name),
search.DateField(name='date',
value=datetime.now().date()),
search.NumberField(name='price', value=price),
search.NumberField(name='mileage', value=mileage),
search.NumberField(name='regdate', value=regdate),
search.TextField(name='type', value=ad.type),
search.TextField(name='currency', value=ad.currency),
search.NumberField(name='company_ad',
value=company_ad),
search.NumberField(name='hour',
value=datetime.now().hour),
search.NumberField(name='minute',
value=datetime.now().minute),
search.NumberField(name='hasimages',
value=hasimages),
search.TextField(name='url', value=ad.url),
search.TextField(name='serving_url', value=serving_url),
], language=language)
search.Index(name='koolbusiness').put(doc)
答案 0 :(得分:1)
2147483647
是32-bit signed binary integer的最大正值,用于此索引。数据存储区中的ID为64位,因此您不能将它们用作NumberField
。
但是,如果你考虑它,那么id是非顺序的,所以你不能通过排序对它们做任何事情,并且只能在查询中使用它们,在这种情况下TextField
就够了。