redis-vl-java icon indicating copy to clipboard operation
redis-vl-java copied to clipboard

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

Open guyroyse opened this issue 5 months ago • 0 comments

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.

guyroyse avatar Jun 25 '26 20:06 guyroyse