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
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')
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()
#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)