FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: qdrant unable to see index_name by jupyterjazz · Pull Request #1705 · docarray/docarray · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 6 additions & 5 deletions docarray/index/backends/qdrant.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class QdrantDocumentIndex(BaseDocIndex, Generic[TSchema]):

def __init__(self, db_config=None, **kwargs):
"""Initialize QdrantDocumentIndex"""
if db_config is not None and getattr(db_config, 'index_name'):
db_config.collection_name = db_config.index_name

super().__init__(db_config=db_config, **kwargs)
self._db_config: QdrantDocumentIndex.DBConfig = cast(
QdrantDocumentIndex.DBConfig, self._db_config
Expand Down Expand Up @@ -101,7 +98,11 @@ def collection_name(self):
'To do so, use the syntax: QdrantDocumentIndex[DocumentType]'
)

return self._db_config.collection_name or default_collection_name
return (
self._db_config.collection_name
or self._db_config.index_name
or default_collection_name
)

@property
def index_name(self):
Expand Down Expand Up @@ -563,7 +564,7 @@ def _text_search_batched(

def _filter_by_parent_id(self, id: str) -> Optional[List[str]]:
response, _ = self._client.scroll(
collection_name=self._db_config.collection_name, # type: ignore
collection_name=self.collection_name, # type: ignore
scroll_filter=rest.Filter(
must=[
rest.FieldCondition(
Expand Down
46 changes: 46 additions & 0 deletions tests/index/qdrant/test_configurations.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import numpy as np
import pytest
from pydantic import Field

from docarray import BaseDoc
from docarray.index import QdrantDocumentIndex
from docarray.typing import NdArray
from tests.index.qdrant.fixtures import start_storage, tmp_collection_name # noqa: F401


pytestmark = [pytest.mark.slow, pytest.mark.index]


def test_configure_dim():
class Schema1(BaseDoc):
tens: NdArray = Field(dim=10)

index = QdrantDocumentIndex[Schema1](host='localhost')

docs = [Schema1(tens=np.random.random((10,))) for _ in range(10)]
index.index(docs)

assert index.num_docs() == 10

class Schema2(BaseDoc):
tens: NdArray[20]

index = QdrantDocumentIndex[Schema2](host='localhost')
docs = [Schema2(tens=np.random.random((20,))) for _ in range(10)]
index.index(docs)

assert index.num_docs() == 10


def test_index_name():
class Schema(BaseDoc):
tens: NdArray = Field(dim=10)

index1 = QdrantDocumentIndex[Schema]()
assert index1.index_name == 'schema'

index2 = QdrantDocumentIndex[Schema](index_name='my_index')
assert index2.index_name == 'my_index'

index3 = QdrantDocumentIndex[Schema](collection_name='my_index')
assert index3.index_name == 'my_index'

Back | FazBrowse Home | New Git URL