def handle(self, *args, **options): doc_classes = [] for label in args: if '.' in label: app_name, doc_name = label.split('.', 1) doc_name = doc_name.lower() for doc_class in app_documents.get(app_name, []): if doc_name == doc_class.__name__.lower(): doc_classes.append(doc_class) break else: doc_classes.extend(app_documents.get(label, [])) if not args: doc_classes.extend(documents) deleted_indexes = [] for doc_class in doc_classes: using = options['using'] or doc_class._index._using or 'default' index = doc_class._index._name es = connections.get_connection(using) update_timestamp_index(index) if options['drop'] and index not in deleted_indexes: if es.indices.exists(index=index): es.indices.delete(index=index) deleted_indexes.append(index) elif options['clear']: doc_class.clear(index=index, using=using) doc_class.init(index=index, using=using) if options['data']: reindex(es, doc_class, index, options)
def handle(self, *args, **options): doc_classes = [] for label in args: doc_classes.extend(app_documents.get(label, [])) if not args: doc_classes.extend(documents) for doc_class in doc_classes: using = options['using'] or doc_class._doc_type.using or 'default' index = options['index'] or doc_class._doc_type.index or getattr(settings, 'SEEKER_INDEX', 'seeker') if options['keep']: doc_class.clear(index=index, using=using, keep_mapping=True) else: doc_class.clear(index=index, using=using) doc_class.init(index=index, using=using) if options['data']: reindex(doc_class, index, using, options) gc.collect()
def handle(self, *args, **options): doc_classes = [] for label in args: doc_classes.extend(app_documents.get(label, [])) if not args: doc_classes.extend(documents) if options['drop']: index = options['index'] or getattr(settings, 'SEEKER_INDEX', 'seeker') es = connections.get_connection(options['using'] or 'default') if es.indices.exists(index=index): es.indices.delete(index=index) for doc_class in doc_classes: using = options['using'] or doc_class._doc_type.using or 'default' index = options['index'] or doc_class._doc_type.index or getattr(settings, 'SEEKER_INDEX', 'seeker') if options['clear'] and not options['drop']: doc_class.clear(index=index, using=using) doc_class.init(index=index, using=using) if options['data']: reindex(doc_class, index, using, options)
def handle(self, *args, **options): doc_classes = [] for label in args: doc_classes.extend(app_documents.get(label, [])) if not args: doc_classes.extend(documents) if options['drop']: index = options['index'] or getattr(settings, 'SEEKER_INDEX', 'seeker') es = connections.get_connection(options['using'] or 'default') if es.indices.exists(index=index): es.indices.delete(index=index) for doc_class in doc_classes: using = options['using'] or doc_class._doc_type.using or 'default' index = options['index'] or doc_class._doc_type.index or getattr( settings, 'SEEKER_INDEX', 'seeker') if options['clear'] and not options['drop']: doc_class.clear(index=index, using=using) doc_class.init(index=index, using=using) if options['data']: reindex(doc_class, index, using, options)