Unable to use search

I am unable to use search. I get the error below from the UI

search backend error. Verify that the search service is available and that the search syntax is valid for the active search backend; ord() expected a character, but string of length 0 found

error recorded on mayan docker image logs

[2024-01-21 11:00:11,467: ERROR/ForkPoolWorker-4] Unexpected error calling `task_index_instance` with keyword arguments {'app_label': 'documents', 'model_name': 'documentfile', 'object_id': 520732, 'exclude_app_label': None, 'exclude_model_name': None, 'exclude_kwargs': None}.
[2024-01-21 11:00:11,469: ERROR/ForkPoolWorker-4] Task mayan.apps.dynamic_search.tasks.task_index_instance[d51597b4-c2fd-4eb8-9fca-629ba6960f9f] raised unexpected: DynamicSearchException("Unexpected error calling `task_index_instance` with keyword arguments {'app_label': 'documents', 'model_name': 'documentfile', 'object_id': 520732, 'exclude_app_label': None, 'exclude_model_name': None, 'exclude_kwargs': None}.")
Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/tasks.py", line 67, in task_index_instance
    SearchBackend.get_instance().index_instance(
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/backends/whoosh.py", line 402, in index_instance
    with self._get_writer(search_model=search_model) as writer:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/backends/whoosh.py", line 277, in _get_writer
    index = self._get_or_create_index(search_model=search_model)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/backends/whoosh.py", line 231, in _get_or_create_index
    index = storage.open_index(
            ^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/filedb/filestore.py", line 176, in open_index
    return indexclass(self, schema=schema, indexname=indexname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 421, in __init__
    TOC.read(self.storage, self.indexname, schema=self._schema)
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 632, in read
    check_size("int", _INT_SIZE)
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 626, in check_size
    sz = stream.read_varint()
         ^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/filedb/structfile.py", line 191, in read_varint
    return read_varint(self.read)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/util/varints.py", line 102, in read_varint
    b = ord(readfn(1))
        ^^^^^^^^^^^^^^
TypeError: ord() expected a character, but string of length 0 found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/mayan-edms/lib/python3.11/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/tasks.py", line 88, in task_index_instance
    raise DynamicSearchException(error_message) from exception
mayan.apps.dynamic_search.exceptions.DynamicSearchException: Unexpected error calling `task_index_instance` with keyword arguments {'app_label': 'documents', 'model_name': 'documentfile', 'object_id': 520732, 'exclude_app_label': None, 'exclude_model_name': None, 'exclude_kwargs': None}

looking up the api routes and search is null? is this normal? I dont think i disabled search.

GET /api/v4/?page=3

RESPONSE

        {
            "label": "search",
            "url": null
        },

Api Search

get: Perform a search operation.

GET /api/v4/search/documents.documentsearchresult/?q=821e9975-5b71-4376-ac19-746ba4beca2a

RESPONSE

**HTTP 200 OK** 
**Allow:** GET, HEAD, OPTIONS 
**Content-Type:** application/json 
**Vary:** Accept

{ 
   "count": 0, 
   "next": null, 
   "previous": null, 
   "results": [] 
}

is there anything i could do to resolve this

Seems Mayan is having problems either reading the Whoosh index file or an entry in the Whoosh index file.

  • Check that the is enough disk space available.
  • That there are no operating system permission issues.

What operation was being performed that caused the issue?
Does this happen with all documents or a specific set of documents?
What is the version of Mayan?

  1. What operation → there was an outage and when the server was back on this error began

  2. Does this happen with all documents or a specific set of documents → all documents

  3. What is the version of Mayan → Version 4.5.7

There seems to be more than enough disk space. I opened a shell in the mayan container and changed the ownership with chown mayan:mayan -R /var/lib/mayan. This still didnt work.

running the command /opt/mayan-edms/bin/mayan-edms.py search_status in the container shell gave the following error.

Traceback (most recent call last):
  File "/opt/mayan-edms/bin/mayan-edms.py", line 22, in <module>
    main()
  File "/opt/mayan-edms/bin/mayan-edms.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/opt/mayan-edms/lib/python3.11/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/mayan-edms/lib/python3.11/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/mayan-edms/lib/python3.11/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/mayan-edms/lib/python3.11/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/management/commands/search_status.py", line 12, in handle
    result = backend.get_status()
             ^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/search_backends.py", line 300, in get_status
    return self._get_status()
           ^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/backends/whoosh.py", line 260, in _get_status
    index = self._get_or_create_index(search_model=search_model)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/mayan/apps/dynamic_search/backends/whoosh.py", line 231, in _get_or_create_index
    index = storage.open_index(
            ^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/filedb/filestore.py", line 176, in open_index
    return indexclass(self, schema=schema, indexname=indexname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 421, in __init__
    TOC.read(self.storage, self.indexname, schema=self._schema)
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 632, in read
    check_size("int", _INT_SIZE)
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/index.py", line 626, in check_size
    sz = stream.read_varint()
         ^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/filedb/structfile.py", line 191, in read_varint
    return read_varint(self.read)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mayan-edms/lib/python3.11/site-packages/whoosh/util/varints.py", line 102, in read_varint
    b = ord(readfn(1))
        ^^^^^^^^^^^^^^
TypeError: ord() expected a character, but string of length 0 found