Skip to content

Filter by column #9

Open
Open
@dbrgn

Description

@dbrgn

Problem

When filtering by a specific column, the column is ignored.

>>> CompanyIndex.objects.filter(company_name__search='my company')
SELECT `id`, `customer_id` FROM companies_rt WHERE MATCH ('@* my company') LIMIT 21

In this case, the correct SphinxQL query would be:

SELECT `id`, `customer_id` FROM companies_rt WHERE MATCH ('@company_name my company') LIMIT 21

This default @* at the beginning of the query causes problems when using the @-Syntax in the filtering query itself.

>>> CompanyIndex.objects.filter(company_name__search='@company_name my company')
SELECT `id`, `customer_id` FROM companies_rt WHERE MATCH ('@* @company_name my company') LIMIT 21

This fails of course.

Suggestion

I'd suggest that the standard query filtering accepts only basic syntax, no field names. It should also limit the filtering to the specified column name.

>>> CompanyIndex.objects.filter(company_name__search='my company')
SELECT `id`, `customer_id` FROM companies_rt WHERE MATCH ('@company_name my company') LIMIT 21

Additionally, you could add an unfiltered matching function, e.g.

>>> CompanyIndex.objects.match('@* software @city new york')

I guess this could be done by adding the function to the custom manager, but I'm not 100% sure about that.

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