Java 动态索引googleappengine
我的应用程序创建并发布各种类型的数据,基本上它对我们的PAAS应用程序进行web服务调用,然后根据响应创建并填充这些类型的数据 因此,问题在于如何创建动态索引,因为在本例中,它不使用app cfg.py(实际上不会使用app cfg.py),因为它是用java编写的,并且已经部署(w.Maven) 我发现了一个在线发布的解决方案,那就是使用python,所以我的想法是托管一个python应用程序,其唯一目的是创建索引 但是,上述解决方案对我不起作用。当我尝试从python应用程序连接时,它返回“缺少必需的头”,或者如果我尝试在java中连接,则找不到url。请注意,我在python版本中使用SACSID,在java版本中使用OAuth 我在网上找不到记录在案的api,当我试图询问帖子的作者时,帖子从未通过 请看这个:您觉得它正确吗?那个api仍然可用吗 我的代码。注意,我对使用UrlFetch做了一些更改Java 动态索引googleappengine,java,python,google-app-engine,indexing,Java,Python,Google App Engine,Indexing,我的应用程序创建并发布各种类型的数据,基本上它对我们的PAAS应用程序进行web服务调用,然后根据响应创建并填充这些类型的数据 因此,问题在于如何创建动态索引,因为在本例中,它不使用app cfg.py(实际上不会使用app cfg.py),因为它是用java编写的,并且已经部署(w.Maven) 我发现了一个在线发布的解决方案,那就是使用python,所以我的想法是托管一个python应用程序,其唯一目的是创建索引 但是,上述解决方案对我不起作用。当我尝试从python应用程序连接时,它返回“
from google.appengine.api import users
from google.appengine.tools import appengine_rpc
import webapp2
import urllib
from google.appengine.api import urlfetch
#START MY STUFF
class MainPage(webapp2.RequestHandler):
def get(self):
host = 'appengine.google.com'
source = 'iristest-publicview.appspot.com'
def auth_function():
return ('<A valid admin username>','<A valid password')
rpc_server = appengine_rpc.HttpRpcServer(host, auth_function, 'Python 2.7', source)
#Authenticate
rpc_server._Authenticate();
if rpc_server.authenticated == True:
print 'Your Authentication Was Successful.'
for cookie in rpc_server.cookie_jar:
if cookie.name and cookie.name == 'SACSID':
print 'Authentication Token Obtained (%s => %s)' % (cookie.name, cookie.value)
#index_payload is description of your indexes in YAML - This can be generated in various different ways.
form_fields = '{ indexes:\n kind:< THE KIND I JUST CREATED DYNAMICALLY > \n properties: \n - name:extId \n direction:asc&app_id=< MY APP'S ID >&version=6 }'
form_data = urllib.quote_plus(form_fields)
url = 'https://appengine.google.com/api/datastore/index/add'
result = urlfetch.fetch(url=url,
payload=form_data,
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie.value, 'Timeout': 60000, 'X-Same-Domain': '1' })
print result.content
print 'Uploading Index Successful'
#END MY STUFF
application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
来自google.appengine.api导入用户
从google.appengine.tools导入appengine\u rpc
导入webapp2
导入URL库
从google.appengine.api导入urlfetch
#开始我的工作
类主页(webapp2.RequestHandler):
def get(自我):
主机='appengine.google.com'
source='iristest publicview.appspot.com'
def auth_函数():
返回(“”,“%s”)%(cookie.name,cookie.value)
#index_payload是对YAML中索引的描述-可以通过各种不同的方式生成。
form_fields='{index:\n kind:<我刚才动态创建的种类>\n属性:\n-name:extId\n方向:asc&app_id=<我的应用的id>&version=6}'
form\u data=urllib.quote\u plus(form\u字段)
url='1〕https://appengine.google.com/api/datastore/index/add'
result=urlfetch.fetch(url=url,
有效载荷=表格数据,
方法=urlfetch.POST,
headers={'Content-Type':'application/x-www-form-urlencoded','Cookie':Cookie.value,'Timeout':60000,'x-Same-Domain':'1'})
打印结果。内容
打印“上传索引成功”
#结束我的东西
application=webapp2.WSGIApplication([
(“/”,主页),
],debug=True)
**