Skip to content

QueryIndexAsync with equal string bounds also returns every key that starts with that value #208

Closed as not planned

Description

@mrdevrobot

Version: main (efacaf4), typed collections, string B-Tree secondary index.

What happens

QueryIndexAsync("idx_name", "g1", "g1") on an index over a string property returns the documents whose name is exactly g1 and also every document whose name starts with g1 (g1001, g1003, …). In the probe that found it, 556 hits instead of one.

String keys are encoded as [0x02][utf-8 bytes] with no terminator, and composite secondary keys are [user key][document id]. The upper bound built by CreateCompositeKeyBoundary(userMaxKey, useMinObjectId: false) (CollectionSecondaryIndex.cs:386-404, helper at :572) appends a maximal id suffix to g1, which sorts after g1001…, so longer values that share the prefix fall inside the range.

Expected

Equal bounds return only the documents whose value equals the bound. A range ["g1", "g2"] should include g1001 (it sorts between them), but ["g1", "g1"] should not.

Possible fix

Bound the user key by its length as well, e.g. use [user key][id prefix byte] .. [user key][id prefix byte + 1] for the upper bound of an inclusive equal key, the same approach #182 uses for the unique check, or add a terminator to string keys in a future key format.

Activity

  1. mrdevrobot commented on Oct 13, 2026

    @mrdevrobot
    ContributorAuthor

    Duplicate of #206, fixed by #214.

  2. moved this from Todo to Done in BLiteon Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions