minh-4T commited on
Commit
eef0254
·
1 Parent(s): 4095dea

fix set_payloaf qdrant

Browse files
Files changed (1) hide show
  1. core/document_ingest_service.py +23 -34
core/document_ingest_service.py CHANGED
@@ -242,47 +242,36 @@ def _get_or_create_deduplicated_points(
242
  "source_updated_at": source_updated_at or existing_payload.get("source_updated_at"),
243
  }
244
 
245
- client.update_payload(
 
246
  collection_name=collection_name,
247
- payload_update=updated_payload,
248
  points=[existing_point_id],
249
  )
250
  logger.info(f"Đã cập nhật years cho hash {content_hash[:8]}...: {merged_years}")
 
 
251
  except Exception as e:
252
  logger.warning(f"Lỗi cập nhật years cho point đã tồn tại: {e}, sẽ tạo point mới")
253
- # Fallback: tạo point mới
254
- point_id = str(uuid.uuid4())
255
- payload = _build_payload(
256
- document, source_object_ref, chunk_text, index, metadata,
257
- academic_year, years, content_hash, source_url,
258
- source_updated_at, source_etag, created_at, effective_source_path
259
- )
260
- points.append(PointStruct(id=point_id, vector=vector, payload=payload))
261
- db_chunk_rows.append(
262
- DocumentChunk(
263
- document_id=document.id,
264
- chunk_index=index,
265
- content_preview=chunk_text[:200],
266
- qdrant_point_id=point_id,
267
- )
268
- )
269
- else:
270
- # Tạo point mới
271
- point_id = str(uuid.uuid4())
272
- payload = _build_payload(
273
- document, source_object_ref, chunk_text, index, metadata,
274
- academic_year, years, content_hash, source_url,
275
- source_updated_at, source_etag, created_at, effective_source_path
276
- )
277
- points.append(PointStruct(id=point_id, vector=vector, payload=payload))
278
- db_chunk_rows.append(
279
- DocumentChunk(
280
- document_id=document.id,
281
- chunk_index=index,
282
- content_preview=chunk_text[:200],
283
- qdrant_point_id=point_id,
284
- )
285
  )
 
286
 
287
  return points, db_chunk_rows
288
 
 
242
  "source_updated_at": source_updated_at or existing_payload.get("source_updated_at"),
243
  }
244
 
245
+ # ✅ Dùng set_payload để cập nhật payload
246
+ client.set_payload(
247
  collection_name=collection_name,
248
+ payload=updated_payload,
249
  points=[existing_point_id],
250
  )
251
  logger.info(f"Đã cập nhật years cho hash {content_hash[:8]}...: {merged_years}")
252
+ # ✅ QUAN TRỌNG: Bỏ qua tạo point mới - vì đã cập nhật point đã tồn tại
253
+ continue
254
  except Exception as e:
255
  logger.warning(f"Lỗi cập nhật years cho point đã tồn tại: {e}, sẽ tạo point mới")
256
+ # Fallback: tạo point mới nếu cập nhật thất bại
257
+ pass
258
+
259
+ # Tạo point mới
260
+ point_id = str(uuid.uuid4())
261
+ payload = _build_payload(
262
+ document, source_object_ref, chunk_text, index, metadata,
263
+ academic_year, years, content_hash, source_url,
264
+ source_updated_at, source_etag, created_at, effective_source_path
265
+ )
266
+ points.append(PointStruct(id=point_id, vector=vector, payload=payload))
267
+ db_chunk_rows.append(
268
+ DocumentChunk(
269
+ document_id=document.id,
270
+ chunk_index=index,
271
+ content_preview=chunk_text[:200],
272
+ qdrant_point_id=point_id,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  )
274
+ )
275
 
276
  return points, db_chunk_rows
277