Ejemplo n.º 1
0
def save_to_elastic(signal_id):
    if not SignalDocument.ping():
        raise Exception('Elastic cluster is unreachable')

    signal = Signal.objects.get(id=signal_id)
    signal_document = SignalDocument.create_document(signal)
    signal_document.save()
Ejemplo n.º 2
0
def save_to_elastic(signal_id):
    if settings.FEATURE_FLAGS.get('SEARCH_BUILD_INDEX', False):
        signal = Signal.objects.get(id=signal_id)
        signal_document = SignalDocument.create_document(signal)
        signal_document.save()
    else:
        log.warning('rebuild_index - elastic indexing disabled')
Ejemplo n.º 3
0
    def _index_signal(self, signal_id):
        self.stdout.write(f'* Index Signal #{signal_id}')

        try:
            signal = Signal.objects.get(pk=signal_id)
        except Signal.DoesNotExist:
            self.stderr.write(f'* Signal #{signal_id} does not exists')
            return None

        if not self._dry_run:
            SignalDocument.init()
            signal_document = SignalDocument.create_document(signal)
            signal_document.save()
Ejemplo n.º 4
0
def delete_from_elastic(signal):
    if not SignalDocument.ping():
        raise Exception('Elastic cluster is unreachable')

    if isinstance(signal, int):
        signal = Signal.objects.get(id=signal)

    signal_document = SignalDocument.create_document(signal)

    try:
        signal_document.delete()
    except NotFoundError:
        log.warning(f'Signal {signal.id} not found in Elasticsearch')