Skip to content

Free-text searches with minus (-) and plus (+) signs do not behave as expected #459

Description

@mcucchi9

version: v0.9.9

Description

I noticed a possible issue with free-text searches (?q=) when the dash (-) symbol is present after an initial word.

From here, I would expect the dash symbol to be translated into the & ! SQL operator, when coming not at the start of the string, only if preceded by a blank space. This sounds reasonable to me, as it would allow for searching dash-separated words, e.g. "first-generation", without it being interpreted as first & ! generation. What I observe, though, is that the - symbol is always interpreted as & !, regardless of the presence of blank spaces before it.

Possible solution

As far as I understand, this behaviour is controlled by this line

processed_text := regexp_replace(processed_text, '\s*\-([a-zA-Z0-9_]+)', ' & ! \1', 'g'); -- -term elsewhere

A possible could be to replace it with

processed_text := regexp_replace(processed_text, '\s+\-([a-zA-Z0-9_]+)', ' & ! \1', 'g');

The same considerations apply to the + term.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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