Make a single batch TF-IDF search request
(batch_queries, batch_index)
| 567 | ) |
| 568 | |
| 569 | def make_batch_request(batch_queries, batch_index): |
| 570 | """Make a single batch TF-IDF search request""" |
| 571 | try: |
| 572 | batch_result = collection.search.batch_text( |
| 573 | query_texts=batch_queries, top_k=top_k, return_raw_text=False |
| 574 | ) |
| 575 | |
| 576 | # Extract results from batch response |
| 577 | if "responses" in batch_result: |
| 578 | results = [ |
| 579 | response.get("results", []) |
| 580 | for response in batch_result["responses"] |
| 581 | ] |
| 582 | else: |
| 583 | # Handle direct list response format |
| 584 | results = batch_result if isinstance(batch_result, list) else [] |
| 585 | |
| 586 | return batch_index, results, True |
| 587 | |
| 588 | except Exception as e: |
| 589 | print(f"Batch {batch_index} failed: {e}") |
| 590 | return batch_index, [], False |
| 591 | |
| 592 | # Prepare all batches with their indices for proper ordering |
| 593 | batch_data = [] |