Flarum (2.x)
    Preparing search index...

    Interface IGambit<Type>

    interface IGambit<Type extends GambitType = GambitType> {
        predicates: boolean;
        type: GambitType;
        canonicalPattern?(): string;
        enabled(): boolean;
        filterKey(): string;
        fromFilter(value: any, negate: boolean): string;
        pattern(): string;
        suggestion(): Type extends KeyValue
            ? KeyValueGambitSuggestion
            : GroupedGambitSuggestion;
        toFilter(matches: string[], negate: boolean): Record<string, any>;
    }

    Type Parameters

    Implemented by

    Index
    predicates: boolean

    Whether this gambit can use logical operators. For example, the tag gambit can be used as such: tag:foo,bar tag:baz which translates to (foo OR bar) AND baz.

    The info allows generation of the correct filtering format, which would be

    {
    tag: [
    'foo,bar', // OR because of the comma.
    'baz', // AND because it's a separate item.
    ]
    }

    The backend filter must be able to handle this format. Checkout the TagGambit and TagFilter classes for an example.

    • The canonical English pattern for this gambit, used as an alias so that English always works regardless of the active locale. Implementations should derive this from canonicalKey() rather than key(). Optional, so gambits that implement this interface directly keep working.

      Returns string

    • This is the regular expression pattern that will be used to match the gambit. The pattern language can be localized. for example, the pattern for the author gambit is author:(.+) in English, but auteur:(.+) in French.

      Returns string