@@ -144,6 +144,10 @@ def create_collection(self, collection_name: str, vector_size: int):
144
144
self ._client .create_payload_index (
145
145
collection_name , Field .DOC_ID .value , field_schema = PayloadSchemaType .KEYWORD
146
146
)
147
+ # create document_id payload index
148
+ self ._client .create_payload_index (
149
+ collection_name , Field .DOCUMENT_ID .value , field_schema = PayloadSchemaType .KEYWORD
150
+ )
147
151
# create full text index
148
152
text_index_params = TextIndexParams (
149
153
type = TextIndexType .TEXT ,
@@ -318,23 +322,17 @@ def text_exists(self, id: str) -> bool:
318
322
def search_by_vector (self , query_vector : list [float ], ** kwargs : Any ) -> list [Document ]:
319
323
from qdrant_client .http import models
320
324
321
- filter = models .Filter (
322
- must = [
323
- models .FieldCondition (
324
- key = "group_id" ,
325
- match = models .MatchValue (value = self ._group_id ),
326
- ),
327
- ],
328
- )
325
+ filter = None
329
326
document_ids_filter = kwargs .get ("document_ids_filter" )
330
327
if document_ids_filter :
331
- if filter . must :
332
- filter . must . append (
328
+ filter = models . Filter (
329
+ must = [
333
330
models .FieldCondition (
334
331
key = "metadata.document_id" ,
335
332
match = models .MatchAny (any = document_ids_filter ),
336
333
)
337
- )
334
+ ],
335
+ )
338
336
results = self ._client .search (
339
337
collection_name = self ._collection_name ,
340
338
query_vector = query_vector ,
@@ -369,23 +367,17 @@ def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]:
369
367
"""
370
368
from qdrant_client .http import models
371
369
372
- scroll_filter = models .Filter (
373
- must = [
374
- models .FieldCondition (
375
- key = "page_content" ,
376
- match = models .MatchText (text = query ),
377
- )
378
- ]
379
- )
370
+ scroll_filter = None
380
371
document_ids_filter = kwargs .get ("document_ids_filter" )
381
372
if document_ids_filter :
382
- if scroll_filter . must :
383
- scroll_filter . must . append (
373
+ scroll_filter = models . Filter (
374
+ must = [
384
375
models .FieldCondition (
385
376
key = "metadata.document_id" ,
386
377
match = models .MatchAny (any = document_ids_filter ),
387
378
)
388
- )
379
+ ]
380
+ )
389
381
response = self ._client .scroll (
390
382
collection_name = self ._collection_name ,
391
383
scroll_filter = scroll_filter ,
0 commit comments