Пример #1
0
 def setUp(self):
     client = OpensearchClientFactory.create_client("hangzhou", "external", "XVqTa2Rl5fGpml7c", "ZRXQN8Azm15Z7bWKgD0zVzS0OJR6A9")
     self.data_mgr = DataMgr(client)
Пример #2
0
from __future__ import unicode_literals

__author__ = 'barycenter'

from opensearchsdk import utils
from opensearchsdk.core.client import OpensearchClientFactory
from opensearchsdk.service.application import ApplicationMgr
from opensearchsdk.service.data import DataMgr
from opensearchsdk.service.search import Search, Q
from opensearchsdk.config import Config

# if you want to open debug log, please set it to True
Config.DEBUG = True

# create a client, this is singleton
client = OpensearchClientFactory.create_client("hangzhou", "external", "XVqTa2Rl5fGpml7c", "ZRXQN8Azm15Z7bWKgD0zVzS0OJR6A9")

# create a application
# ApplicationMgr is thread safe
app = ApplicationMgr(client)
app_name = utils.get_random_str(6)
# make sure you have created a template named default2 manually
resp = app.create(app_name, "default2")

# you could get mission result by:
if resp.success():
    print("create app %s success" % app_name)

# and you could get return json object
print(resp.result)