Skip to content

elasticsearch.helpers.BulkIndexError: 1 document(s) failed to index #474

Open
@pulse-mind

Description

@pulse-mind

Hello,

I'm having this error

File "/Users/pulsemind/.virtualenvs/vdatac/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 521, in bulk
    for ok, item in streaming_bulk(
  File "/Users/pulsemind/.virtualenvs/vdatac/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 436, in streaming_bulk
    for data, (ok, info) in zip(
  File "/Users/pulsemind/.virtualenvs/vdatac/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 355, in _process_bulk_chunk
    yield from gen
  File "/Users/pulsemind/.virtualenvs/vvdatac/lib/python3.10/site-packages/elasticsearch/helpers/actions.py", line 274, in _process_bulk_chunk_success
    raise BulkIndexError(f"{len(errors)} document(s) failed to index.", errors)
elasticsearch.helpers.BulkIndexError: 1 document(s) failed to index.

when running
python manage.py search\_index --rebuild

I had some difficulties to know which Document is having a problem ? why ? ... ?

Nothing in the logs : /opt/homebrew/var/log/elasticsearch/elasticsearch...

(I am new with elastic search)

Actually I changed the source code locally to do :

 if errors:
     raise BulkIndexError(f"{len(errors)} document(s) failed to index: {errors}", errors)

which is not nice if there are a lot of errors but in my case it helps me to understand what's going on.

If I look at the command, the rebuild is called like this:

    def handle(self, *args, **options):
        if not options['action']:
            raise CommandError(
                "No action specified. Must be one of"
                " '--create','--populate', '--delete' or '--rebuild' ."
            )

        action = options['action']
        models = self._get_models(options['models'])

        # We need to know if and which aliases exist to mitigate naming
        # conflicts with indices, therefore this is needed regardless
        # of using the '--use-alias' arg.
        aliases = []
        for index in self.es_conn.indices.get_alias().values():
            aliases += index['aliases'].keys()

        if action == 'create':
            self._create(models, aliases, options)
        elif action == 'populate':
            self._populate(models, options)
        elif action == 'delete':
            self._delete(models, aliases, options)
        elif action == 'rebuild':
            self._rebuild(models, aliases, options)
        else:
            raise CommandError(
                "Invalid action. Must be one of"
                " '--create','--populate', '--delete' or '--rebuild' ."
            )

So there is no way to get the errors here.
It would be good to add something like I did (with a better formatting) ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions