Skip to content

MessageHistory single-use per index: resume / second session throws SEARCH_INDEX_EXISTS #31

Description

@guyroyse

SearchIndex.create(boolean overwrite, boolean drop) only drops-then-recreates when overwrite is true; otherwise it falls through to an unconditional FT.CREATE, which throws SEARCH_INDEX_EXISTS if the index already exists. There is no "attach if present" branch.

MessageHistory's constructor calls create(false), so you get exactly one MessageHistory per index name for that index's lifetime — resuming a conversation or opening a second session_tag both throw mid-construction. SemanticMessageHistory is affected the same way via its default overwrite=false constructors.

Root cause

public void create(boolean overwrite, boolean drop) {
  if (overwrite && exists()) {
    delete(drop);
  }
  create(); // unconditional FT.CREATE — nothing guards on exists() when overwrite == false
}

Expected

Match Python's create(overwrite=False): when the index already exists and overwrite is false, attach to it and return instead of recreating.

Verified against main.

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