-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinterfaces.py
42 lines (35 loc) · 1.05 KB
/
interfaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import abc
from typing import Dict, Iterable
class IndexInterface(abc.ABC):
"""
Interface to abstract the interaction with the index system
"""
@abc.abstractmethod
def create_index(self, index_name: str, body: Dict) -> None:
"""
Create the index used by the application
"""
@abc.abstractmethod
def refresh_index(self, index_name: str) -> None:
"""
Refreshes the index to make it up-to-date for future searches
"""
@abc.abstractmethod
def index_document(
self, document: Dict, document_id: str, index: str, refresh: bool
) -> None:
"""
Upload document to the index
"""
@abc.abstractmethod
def search(self, query: Dict, index: str) -> Dict:
"""
Searches the index with the provided query
"""
@abc.abstractmethod
def paginated_search(
self, query: Dict, index: str, keep_alive: str
) -> Iterable[Dict]:
"""
Searches the index with the provided query, with pagination
"""