Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f9e504e

Browse filesBrowse files
authored
refactor: minor changes in weaviate (#1621)
Signed-off-by: jupyterjazz <saba.sturua@jina.ai>
1 parent ac2e417 commit f9e504e
Copy full SHA for f9e504e

2 files changed

+10-20Lines changed: 10 additions & 20 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docarray/index/backends/elastic.py‎

Copy file name to clipboardExpand all lines: docarray/index/backends/elastic.py
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ def _index(
371371
refresh: bool = True,
372372
chunk_size: Optional[int] = None,
373373
):
374-
375374
self._index_subindex(column_to_data)
376375

377376
data = self._transpose_col_value_dict(column_to_data)
@@ -479,7 +478,6 @@ def execute_query(self, query: Dict[str, Any], *args, **kwargs) -> Any:
479478
def _find(
480479
self, query: np.ndarray, limit: int, search_field: str = ''
481480
) -> _FindResult:
482-
483481
body = self._form_search_body(query, limit, search_field)
484482

485483
resp = self._client_search(**body)
@@ -494,7 +492,6 @@ def _find_batched(
494492
limit: int,
495493
search_field: str = '',
496494
) -> _FindResultBatched:
497-
498495
request = []
499496
for query in queries:
500497
head = {'index': self.index_name}
@@ -513,7 +510,6 @@ def _filter(
513510
filter_query: Dict[str, Any],
514511
limit: int,
515512
) -> List[Dict]:
516-
517513
resp = self._client_search(query=filter_query, size=limit)
518514

519515
docs, _ = self._format_response(resp)
@@ -525,7 +521,6 @@ def _filter_batched(
525521
filter_queries: Any,
526522
limit: int,
527523
) -> List[List[Dict]]:
528-
529524
request = []
530525
for query in filter_queries:
531526
head = {'index': self.index_name}
@@ -543,7 +538,6 @@ def _text_search(
543538
limit: int,
544539
search_field: str = '',
545540
) -> _FindResult:
546-
547541
body = self._form_text_search_body(query, limit, search_field)
548542
resp = self._client_search(**body)
549543

@@ -557,7 +551,6 @@ def _text_search_batched(
557551
limit: int,
558552
search_field: str = '',
559553
) -> _FindResultBatched:
560-
561554
request = []
562555
for query in queries:
563556
head = {'index': self.index_name}
@@ -571,7 +564,6 @@ def _text_search_batched(
571564
return _FindResultBatched(documents=list(das), scores=scores)
572565

573566
def _filter_by_parent_id(self, id: str) -> List[str]:
574-
575567
resp = self._client_search(
576568
query={'term': {'parent_id': id}}, fields=['id'], _source=False
577569
)
@@ -676,35 +668,28 @@ def _format_response(self, response: Any) -> Tuple[List[Dict], List[Any]]:
676668
return docs, [parse_obj_as(NdArray, np.array(s)) for s in scores]
677669

678670
def _refresh(self, index_name: str):
679-
680671
self._client.indices.refresh(index=index_name)
681672

682673
###############################################
683674
# API Wrappers #
684675
###############################################
685676

686677
def _client_put_mapping(self, mappings: Dict[str, Any]):
687-
688678
self._client.indices.put_mapping(
689679
index=self.index_name, properties=mappings['properties']
690680
)
691681

692682
def _client_create(self, mappings: Dict[str, Any]):
693-
694683
self._client.indices.create(index=self.index_name, mappings=mappings)
695684

696685
def _client_put_settings(self, settings: Dict[str, Any]):
697-
698686
self._client.indices.put_settings(index=self.index_name, settings=settings)
699687

700688
def _client_mget(self, ids: Sequence[str]):
701-
702689
return self._client.mget(index=self.index_name, ids=ids)
703690

704691
def _client_search(self, **kwargs):
705-
706692
return self._client.search(index=self.index_name, **kwargs)
707693

708694
def _client_msearch(self, request: List[Dict[str, Any]]):
709-
710695
return self._client.msearch(index=self.index_name, searches=request)
Collapse file

‎docarray/index/backends/weaviate.py‎

Copy file name to clipboardExpand all lines: docarray/index/backends/weaviate.py
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def _find(
388388
index_name = self.index_name
389389
if search_field:
390390
logging.warning(
391-
'Argument search_field is not supported for WeaviateDocumentIndex. Ignoring.'
391+
'The search_field argument is not supported for the WeaviateDocumentIndex and will be ignored.'
392392
)
393393
near_vector: Dict[str, Any] = {
394394
"vector": query,
@@ -435,7 +435,7 @@ def find_batched(
435435
queries: Union[AnyTensor, DocList],
436436
search_field: str = '',
437437
limit: int = 10,
438-
**kwargs,
438+
**kwargs: Any,
439439
) -> FindResultBatched:
440440
"""Find documents in the index using nearest neighbor search.
441441
@@ -770,7 +770,7 @@ def __init__(self, document_index):
770770
)
771771
]
772772

773-
def build(self) -> Any:
773+
def build(self, *args, **kwargs) -> Any:
774774
"""Build the query object."""
775775
num_queries = len(self._queries)
776776

@@ -831,6 +831,7 @@ def find(
831831
query,
832832
score_name: Literal["certainty", "distance"] = "certainty",
833833
score_threshold: Optional[float] = None,
834+
**kwargs,
834835
) -> Any:
835836
"""
836837
Find k-nearest neighbors of the query.
@@ -840,6 +841,11 @@ def find(
840841
:param score_threshold: the threshold of the score
841842
:return: self
842843
"""
844+
if kwargs.get('search_field'):
845+
logging.warning(
846+
'The search_field argument is not supported for the WeaviateDocumentIndex and will be ignored.'
847+
)
848+
843849
near_vector = {
844850
"vector": query,
845851
}
@@ -883,7 +889,7 @@ def find_batched(
883889

884890
return self
885891

886-
def filter(self, where_filter) -> Any:
892+
def filter(self, where_filter: Any) -> Any:
887893
"""Find documents in the index based on a filter query
888894
:param where_filter: a filter
889895
:return: self
@@ -913,7 +919,6 @@ def filter_batched(self, filters) -> Any:
913919
return self
914920

915921
def text_search(self, query: str, search_field: Optional[str] = None) -> Any:
916-
917922
"""Find documents in the index based on a text search query
918923
919924
:param query: The text to search for

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.