本文整理汇总了Python中pyes.ES.create_index_if_missing方法的典型用法代码示例。如果您正苦于以下问题:Python ES.create_index_if_missing方法的具体用法?Python ES.create_index_if_missing怎么用?Python ES.create_index_if_missing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyes.ES
的用法示例。
在下文中一共展示了ES.create_index_if_missing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_store
# 需要导入模块: from pyes import ES [as 别名]
# 或者: from pyes.ES import create_index_if_missing [as 别名]
def setup_store():
connection = ES(settings.THUMBNAIL_ELASTIC_SEARCH_SERVERS)
try:
connection.create_index_if_missing(settings.THUMBNAIL_ELASTIC_SEARCH_INDEX)
except:
pass
try:
connection.put_mapping(settings.THUMBNAIL_ELASTIC_SEARCH_DOCUMENT_TYPE,
settings.THUMBNAIL_ELASTIC_SEARCH_MAPPING,
indexes=[settings.THUMBNAIL_ELASTIC_SEARCH_INDEX,])
except:
pass
示例2: main
# 需要导入模块: from pyes import ES [as 别名]
# 或者: from pyes.ES import create_index_if_missing [as 别名]
def main(options):
es = ES([options.es_server])
try:
es.create_index_if_missing('bzcache')
except ElasticSearchException:
# create_index_if_missing is supposed not to raise if the index
# already existing, but with the ancient pyes / ES server versions
# we're using it still does.
pass
# re-cache all intermittent-failure bugs
bzcache = BugzillaCache(es_server=options.es_server)
bzcache.index_bugs_by_keyword('intermittent-failure')
示例3: handle
# 需要导入模块: from pyes import ES [as 别名]
# 或者: from pyes.ES import create_index_if_missing [as 别名]
def handle(self, *args, **kwargs):
init_all = kwargs.get('all')
elastic = ES(settings.SEARCH_HOSTS)
aliases = settings.SEARCH_ALIASES if init_all else args
indices_new = []
for alias in aliases:
index_new = '%s_%d' % (alias, int(time.time()))
indices_new.append(index_new)
elastic.create_index_if_missing(index_new)
elastic.add_alias(alias, [index_new])
if len(aliases):
elastic.put_mapping('job', {'job':{'properties':mapping}}, indices_new)
self.stdout.write("Successfully created indices mapping.\n")
elastic.connection.close()
示例4: Flask
# 需要导入模块: from pyes import ES [as 别名]
# 或者: from pyes.ES import create_index_if_missing [as 别名]
#import logging
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.assets import Environment
from pyes import ES
from datawire import default_settings
#logging.basicConfig(level=logging.WARN)
app = Flask(__name__)
app.config.from_object(default_settings)
app.config.from_envvar('DATAWIRE_SETTINGS', silent=True)
db = SQLAlchemy(app)
assets = Environment(app)
elastic_index = app.config.get('ELASTICSEARCH_INDEX', 'datawire')
elastic = ES(app.config.get('ELASTICSEARCH_SERVER', '127.0.0.1:9200'),
default_indices=elastic_index)
elastic.create_index_if_missing(elastic_index)
#js = Bundle('jquery.js', 'base.js', 'widgets.js',
# filters='jsmin', output='gen/packed.js')
#assets.register('js_all', js)