66from pydantic import HttpUrl
77from rre_tools .shared .models .document import Document
88
9- DOC_NUMBER_EACH_FETCH = 100
9+ NUMBER_OF_DOCS_EACH_FETCH = 100
1010
1111class BaseSearchEngine (ABC ):
1212 def __init__ (self , endpoint : HttpUrl ):
@@ -31,18 +31,18 @@ def fetch_all(self, doc_fields: List[str]) -> Iterator[Document]:
3131 while start < total_hits :
3232 batch = self .fetch_for_query_generation (
3333 documents_filter = None ,
34- doc_number = DOC_NUMBER_EACH_FETCH ,
34+ number_of_docs = NUMBER_OF_DOCS_EACH_FETCH ,
3535 doc_fields = doc_fields ,
3636 start = start
3737 )
3838 if not batch :
3939 break
4040 for doc in batch :
4141 yield doc
42- # if we didn't reach the end of the docs, then len(batch) == DOC_NUMBER_EACH_FETCH
43- # if we reached the end of the docs. then len(batch) <= DOC_NUMBER_EACH_FETCH -> next iteration we exit the
44- # loop since we are adding DOC_NUMBER_EACH_FETCH (not len(batch)) and start becomes greater than total_hits
45- start += DOC_NUMBER_EACH_FETCH
42+ # if we didn't reach the end of the docs, then len(batch) == NUMBER_OF_DOCS_EACH_FETCH if we reached the
43+ # end of the docs. then len(batch) <= NUMBER_OF_DOCS_EACH_FETCH -> next iteration we exit the loop since
44+ # we are adding NUMBER_OF_DOCS_EACH_FETCH (not len(batch)) and start becomes greater than total_hits
45+ start += NUMBER_OF_DOCS_EACH_FETCH
4646
4747
4848 def _parse_query_template (self , path : Path | str ) -> Dict [str , Any ]:
@@ -72,7 +72,7 @@ def _replace_placeholder(self, obj: Any, placeholder: str, keyword: str | None)
7272 @abstractmethod
7373 def fetch_for_query_generation (self ,
7474 documents_filter : Union [None , List [Dict [str , List [str ]]]],
75- doc_number : int ,
75+ number_of_docs : int ,
7676 doc_fields : List [str ],
7777 start : int = 0 ) \
7878 -> List [Document ]:
0 commit comments