fix(vector): address PR review round 13 — index offset fields + tighten test
- Add chunk_start_offset / chunk_end_offset to _PAYLOAD_INDEX_FIELDS so the legacy offset-based fallback in search/context.py works on Qdrant Cloud strict mode (pre-#75 clients have no chunk_index payload). - Cover chunk_index / chunk_start_offset / chunk_end_offset in the payload-index summary test; refresh the stale field-list comment. - Flag the is_valid_nextcloud_doc_id gate at both chunk-context handler sites with a TODO for future non-numeric doc_types. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
f9ad7dc52e
commit
ae23bbe8b8
@@ -505,6 +505,9 @@ async def get_chunk_context(request: Request) -> JSONResponse:
|
||||
# ints from MySQL auto_increment; doc_id stays a str downstream
|
||||
# (Qdrant payload index is keyword-typed). is_valid_nextcloud_doc_id
|
||||
# rejects "0", leading zeros, and Unicode digits that pass isdigit().
|
||||
# TODO: when chunk-context support extends to non-numeric doc_types
|
||||
# (calendar VEVENT UIDs, CardDAV hrefs, …), relax this gate or make
|
||||
# it doc_type-aware. Today every indexed doc_type is numeric.
|
||||
if not is_valid_nextcloud_doc_id(doc_id):
|
||||
return JSONResponse(
|
||||
{
|
||||
|
||||
@@ -567,6 +567,9 @@ async def chunk_context_endpoint(request: Request) -> JSONResponse:
|
||||
# ints from MySQL auto_increment; doc_id stays a str downstream
|
||||
# (Qdrant payload index is keyword-typed). is_valid_nextcloud_doc_id
|
||||
# rejects "0", leading zeros, and Unicode digits that pass isdigit().
|
||||
# TODO: when chunk-context support extends to non-numeric doc_types
|
||||
# (calendar VEVENT UIDs, CardDAV hrefs, …), relax this gate or make
|
||||
# it doc_type-aware. Today every indexed doc_type is numeric.
|
||||
if not is_valid_nextcloud_doc_id(doc_id):
|
||||
return JSONResponse(
|
||||
{
|
||||
|
||||
@@ -31,13 +31,18 @@ logger = logging.getLogger(__name__)
|
||||
# ``_get_chunk_by_index_from_qdrant`` and ``get_chunk_bbox_and_page_from_qdrant``
|
||||
# (see search/context.py) — the always-indexed fast path that the offset-based
|
||||
# fallback exists to avoid; it has to actually be indexed for that promise to
|
||||
# hold on Qdrant Cloud strict mode.
|
||||
# hold on Qdrant Cloud strict mode. chunk_start_offset / chunk_end_offset are
|
||||
# the ints used by the legacy offset fallback in the same module — pre-#75
|
||||
# clients have no chunk_index payload, so the offset path still has to work
|
||||
# (or 400 silently and return None on Qdrant Cloud strict mode).
|
||||
_PAYLOAD_INDEX_FIELDS: dict[str, PayloadSchemaType] = {
|
||||
"doc_id": PayloadSchemaType.KEYWORD,
|
||||
"user_id": PayloadSchemaType.KEYWORD,
|
||||
"doc_type": PayloadSchemaType.KEYWORD,
|
||||
"is_placeholder": PayloadSchemaType.BOOL,
|
||||
"chunk_index": PayloadSchemaType.INTEGER,
|
||||
"chunk_start_offset": PayloadSchemaType.INTEGER,
|
||||
"chunk_end_offset": PayloadSchemaType.INTEGER,
|
||||
}
|
||||
|
||||
# Sentinel point that records "this collection has been backfilled to str
|
||||
|
||||
Reference in New Issue
Block a user