Skip to content

fix: avoid numpy truth-value ambiguity in keyword/structured search#56

Open
msaidbilgehan wants to merge 1 commit intoaiming-lab:mainfrom
msaidbilgehan:fix/keyword-search-numpy-truth-value
Open

fix: avoid numpy truth-value ambiguity in keyword/structured search#56
msaidbilgehan wants to merge 1 commit intoaiming-lab:mainfrom
msaidbilgehan:fix/keyword-search-numpy-truth-value

Conversation

@msaidbilgehan
Copy link
Copy Markdown

Summary

  • Fixes Keyword search error: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() surfaced in server logs during hybrid or structured search.
  • Root cause: row["keywords"] or [] (same pattern for persons, entities) evaluates bool(numpy_array), since LanceDB's to_pandas() returns list columns as numpy arrays.
  • Aligns with the is not None idiom already used when constructing MemoryEntry objects in the same file.

Test plan

  • memory_add single insert — no log error
  • memory_add_batch bulk insert — no log error
  • memory_query (exercises keyword_search over 50+ rows) — no log error
  • Parallel queries under concurrent batch writes — zero occurrences of truth value / ambiguous in docker logs

…eads

LanceDB returns `keywords`, `persons`, and `entities` columns as numpy
arrays when read via `table.to_pandas()`. The existing `row["col"] or []`
pattern triggers `ValueError: The truth value of an array with more than
one element is ambiguous. Use a.any() or a.all()` because Python evaluates
`bool(array)` for the `or` short-circuit.

Replace the three occurrences in `keyword_search` and `structured_search`
with the `is not None` idiom already used elsewhere in the file when
building `MemoryEntry` objects, so behavior is consistent and safe for
numpy-backed rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant