本文整理汇总了Python中elasticsearch.client.IndicesClient.close方法的典型用法代码示例。如果您正苦于以下问题:Python IndicesClient.close方法的具体用法?Python IndicesClient.close怎么用?Python IndicesClient.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elasticsearch.client.IndicesClient
的用法示例。
在下文中一共展示了IndicesClient.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Elasticsearch
# 需要导入模块: from elasticsearch.client import IndicesClient [as 别名]
# 或者: from elasticsearch.client.IndicesClient import close [as 别名]
from elasticsearch import Elasticsearch
from elasticsearch.client import IndicesClient
from elasticsearch_dsl import Mapping, String, Search
es = Elasticsearch()
ies = IndicesClient(es)
ies.delete('test')
ies.create('test')
ies.close('test')
ies.put_settings(index='test', body={
"analysis":{
"analyzer":{
"default":{
"type":"custom",
"tokenizer":"standard",
"filter":[ "standard", "lowercase", "stop", "kstem" ]
}
}
}
})
m = Mapping('test')
m.field('f', String())
m.save(index='test', using=es)
ies.open(index='test')
示例2: get_client_and_close_indices
# 需要导入模块: from elasticsearch.client import IndicesClient [as 别名]
# 或者: from elasticsearch.client.IndicesClient import close [as 别名]
def get_client_and_close_indices(es, indices):
indices_client = IndicesClient(es)
indices_client.close(indices)
return indices_client
示例3: Elasticsearch
# 需要导入模块: from elasticsearch.client import IndicesClient [as 别名]
# 或者: from elasticsearch.client.IndicesClient import close [as 别名]
parser.add_argument('--indices', dest = 'indices', action = 'store', required = True)
parser.add_argument('--snapshot', dest = 'snapshot', action = 'store', required = True)
args = parser.parse_args()
# --
# Config
config = json.load(open('config.json'))
config_private = json.load(open('config-private.json'))
# --
# Run
client = Elasticsearch([{'host' : config['ES_HOST'], 'port' : config['ES_PORT']}], timeout = 20)
sc = SnapshotClient(client)
ic = IndicesClient(client)
try:
ic.close(index = args.indices)
except:
print '! could not close index'
_ = sc.restore(
repository = config['REPO_NAME'],
snapshot = args.snapshot,
body = {"indices" : args.indices},
wait_for_completion = True
)
ic.open(index = args.indices)