mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-12 22:42:13 +02:00
refactor(chunks): order chunk reads by (document_id, position)
Presentation and citation ordering moves off Chunk.id/created_at to the explicit position column (id kept as tiebreaker). Vector and ts_rank ranking order_by clauses are untouched.
This commit is contained in:
parent
5a71769dba
commit
052e9ef4d1
9 changed files with 28 additions and 19 deletions
|
|
@ -156,7 +156,7 @@ async def _resolve_document_text(
|
|||
stmt = (
|
||||
select(Chunk.content)
|
||||
.where(Chunk.document_id == document.id)
|
||||
.order_by(Chunk.id)
|
||||
.order_by(Chunk.position, Chunk.id)
|
||||
.limit(_MAX_CHUNKS_FOR_CONTEXT)
|
||||
)
|
||||
result = await session.execute(stmt)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ async def _get_document_markdown(
|
|||
chunk_result = await session.execute(
|
||||
select(Chunk.content)
|
||||
.filter(Chunk.document_id == document.id)
|
||||
.order_by(Chunk.id)
|
||||
.order_by(Chunk.position, Chunk.id)
|
||||
)
|
||||
chunks = chunk_result.scalars().all()
|
||||
if chunks:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue