Skip to content

No index on search_names #294

@ronny-rentner

Description

@ronny-rentner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions