Searches with special characters result in internal server error - mysql db

Search results that have a special character in them are causing internal server errors. The database is a MySQL database. Here’s the error with Debug set to true. The search was for “water & fire” in this instance. Any thoughts on why this is happening?

ProgrammingError at /search/

(1064, “syntax error, unexpected ‘)’”)

Request Method: GET
Request URL: https://domainremoved.com/search/?q=water+%26+fire
Django Version: 3.2.9
Exception Type: ProgrammingError
Exception Value: (1064, “syntax error, unexpected ‘)’”)
Exception Location: /var/www/sites/library-test2/.venv/lib64/python3.8/site-packages/MySQLdb/connections.py, line 259, in query
Python Executable: /var/www/sites/library-test2/.venv//bin/python
Python Version: 3.8.8
Python Path: [’/var/www/sites/library-test2’, ‘/usr/lib64/python38.zip’, ‘/usr/lib64/python3.8’, ‘/usr/lib64/python3.8/lib-dynload’, ‘/var/www/sites/library-test2/.venv/lib64/python3.8/site-packages’, ‘/var/www/sites/library-test2/.venv/lib/python3.8/site-packages’]

What package is doing that search? Is it a third-party package or is it code you’ve written?

If it’s code you’ve written, please post the view here.

It is the elastic search from wagtail

WAGTAILSEARCH_BACKENDS = {
‘default’: {
‘BACKEND’: ‘wagtail.search.backends.database’,
}
}

and have mysqlclient installed in the python virtual environment

Ok, so you’re dealing with two separate third-party projects.

While there are some people here who use Wagtail, you may get a faster and more directed response from a forum or mailing list focused on Wagtail. This might not be the best place for you to ask this question. (I don’t see too many Wagtail-specific conversations here.)

Thanks! I’ll look into some Wagtail specific forums.