Skip to content

ngrambf_v1 index produces false negatives for LIKE patterns with backslash-escaped non-special characters #51154

Open

Description

@dstruck

Repro

Fiddle

CREATE TABLE test (
  `data` String,
  INDEX test_idx data TYPE ngrambf_v1(2, 1024, 3, 0) GRANULARITY 1
) ENGINE = MergeTree ORDER BY (data);
INSERT INTO test VALUES ('aaa\\bbb');

-- Returns 1 row (correct)
SELECT * FROM test WHERE data LIKE '%a\\b%' SETTINGS ignore_data_skipping_indices='test_idx';

-- Returns 0 rows (false negative)
SELECT * FROM test WHERE data LIKE '%a\\b%';

Both should return the same result. Switching backslash to some other random character (like forward slash) works as expected

Activity

  1. added
    potential bug
    on Jun 19, 2023
  2. changed the title [-]The ngrambf_v1 index, dependent on the window size, can yield inconsistent results for LIKE queries on strings that contain backslashes.[/-] [+]`ngrambf_v1` index produces false negatives for `LIKE` patterns with backslash-escaped non-special characters[/+] on Mar 30, 2026
  3. added
    bug
    comp-skip-index
    and removed
    potential bug
    on Mar 30, 2026
  4. rienath commented on Mar 30, 2026

    @rienath
    Member
  5. self-assigned this
    on Mar 30, 2026
  6. rienath commented on Mar 30, 2026

    @rienath
    Member

    Sorry, @scanhex12, made a mistake. You implemented sparse-grams, not general n-grams

  7. added
    external
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcomp-skip-indexexternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions