Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No index on search_names #294

Open
ronny-rentner opened this issue Sep 5, 2024 · 2 comments
Open

No index on search_names #294

ronny-rentner opened this issue Sep 5, 2024 · 2 comments

Comments

@ronny-rentner
Copy link

I am searching for cities using the search_names field. I was surprised to find this code:

# MySQL doesn't support indexing TextFields
INDEX_SEARCH_NAMES = getattr(settings, 'CITIES_LIGHT_INDEX_SEARCH_NAMES', None)
if INDEX_SEARCH_NAMES is None:
    INDEX_SEARCH_NAMES = True
    for database in list(settings.DATABASES.values()):
        if "ENGINE" in database and (
                'mysql' in database.get('ENGINE').lower() or
                'postgresql' in database.get('ENGINE').lower()):
            INDEX_SEARCH_NAMES = False

I am using Postgres. My cities_light_city table has 18 indexes but none on search_names, the field that is intended for search.

It should have an index by default on the search field. The information in settings.py is wrong that MySQL would not support indexes on text fields. The same goes for Postgres which does support indexes on text.

@ronny-rentner
Copy link
Author

From the MySQL docs:

MySQL has support for full-text indexing and searching:

    A full-text index in MySQL is an index of type FULLTEXT.

    Full-text indexes can be used only with [InnoDB](https://dev.mysql.com/doc/refman/8.4/en/innodb-storage-engine.html) or [MyISAM](https://dev.mysql.com/doc/refman/8.4/en/myisam-storage-engine.html) tables, and can be created only for [CHAR](https://dev.mysql.com/doc/refman/8.4/en/char.html), [VARCHAR](https://dev.mysql.com/doc/refman/8.4/en/char.html), or [TEXT](https://dev.mysql.com/doc/refman/8.4/en/blob.html) columns.

https://dev.mysql.com/doc/refman/8.4/en/fulltext-search.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ronny-rentner and others