mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
9331126ba1
Three changes to surface more answer text in search results: - Populate matched_chunk_text for FTS-only hybrid results from content_snippet, preventing fallback to truncated content when vector search has no match - Increase TOP_CHUNKS_PER_RESULT from 3 to 5, catching answers in deeper chunks for large notes (~2700 → ~4500 chars of matched context) - Increase CONTENT_DISPLAY_LIMIT from 2000 to 4000, doubling the safety-net content truncation for results without matched_chunk Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Tests for SearchIndexRow data structure."""
|
|
|
|
from datetime import datetime
|
|
|
|
from basic_memory.repository.search_index_row import SearchIndexRow
|
|
|
|
|
|
def test_content_display_limit_is_4000():
|
|
"""CONTENT_DISPLAY_LIMIT raised to 4000 for richer search result context."""
|
|
assert SearchIndexRow.CONTENT_DISPLAY_LIMIT == 4000
|
|
|
|
|
|
def test_content_truncates_at_display_limit():
|
|
"""Content property truncates content_snippet at CONTENT_DISPLAY_LIMIT."""
|
|
long_text = "a" * 5000
|
|
row = SearchIndexRow(
|
|
project_id=1,
|
|
id=1,
|
|
type="entity",
|
|
file_path="test.md",
|
|
created_at=datetime.now(),
|
|
updated_at=datetime.now(),
|
|
content_snippet=long_text,
|
|
)
|
|
assert len(row.content) == 4000
|
|
assert row.content == long_text[:4000]
|
|
|
|
|
|
def test_content_returns_full_snippet_when_under_limit():
|
|
"""Content property returns full content_snippet when under the limit."""
|
|
short_text = "Short note content"
|
|
row = SearchIndexRow(
|
|
project_id=1,
|
|
id=1,
|
|
type="entity",
|
|
file_path="test.md",
|
|
created_at=datetime.now(),
|
|
updated_at=datetime.now(),
|
|
content_snippet=short_text,
|
|
)
|
|
assert row.content == short_text
|