1
1
from meilisearch ._httprequests import HttpRequests
2
2
from meilisearch .document import Document
3
3
from meilisearch .search import Search
4
- from meilisearch .stat import Stat
4
+ # from meilisearch.stat import Stat
5
5
from meilisearch .setting import Setting
6
6
7
7
# pylint: disable=too-many-ancestors
8
- class Index (Document , Search , Stat , Setting ):
8
+ class Index (Document , Search , Setting ):
9
9
"""
10
10
Indexes routes wrapper
11
11
@@ -19,6 +19,7 @@ class Index(Document, Search, Stat, Setting):
19
19
"""
20
20
index_path = 'indexes'
21
21
update_path = 'updates'
22
+ stat_path = 'stats'
22
23
uid = ""
23
24
24
25
class Update :
@@ -35,6 +36,38 @@ class Update:
35
36
"""
36
37
37
38
39
+ def __init__ (self , parent_path , config , uid = None , name = None ):
40
+ """
41
+ Parameters
42
+ ----------
43
+ config : Config
44
+ Config object containing permission and location of MeiliSearch
45
+ name: str
46
+ Name of the index on which to perform the index actions.
47
+ uid: str
48
+ Uid of the index on which to perform the index actions.
49
+ index_path: str
50
+ Index url path
51
+ """
52
+ self .config = config
53
+ self .name = name
54
+ self .uid = uid
55
+ self .index_path = parent_path
56
+
57
+ class Stat :
58
+ """
59
+ Stats routes wrapper
60
+
61
+ Index's parent that gives access to all the stats methods of MeiliSearch.
62
+ https://docs.meilisearch.com/references/stats.html#get-stat-of-an-index
63
+
64
+ Attributes
65
+ ----------
66
+ stat_path:
67
+ Version url path
68
+ """
69
+
70
+
38
71
def __init__ (self , parent_path , config , uid = None , name = None ):
39
72
"""
40
73
Parameters
@@ -66,7 +99,7 @@ def __init__(self, config, uid):
66
99
"""
67
100
Search .__init__ (self , Index .index_path , config , uid )
68
101
Document .__init__ (self , Index .index_path , config , uid )
69
- Stat .__init__ (self , Index .index_path , config , uid )
102
+ # Stat.__init__(self, Index.index_path, config, uid)
70
103
Setting .__init__ (self , Index .index_path , config , uid )
71
104
self .config = config
72
105
self .uid = uid
@@ -224,3 +257,22 @@ def get_update_status(self, update_id):
224
257
update_id
225
258
)
226
259
)
260
+
261
+ def get_stats (self ):
262
+ """Get stats of an index
263
+
264
+ Get information about number of documents, fieldsfrequencies, ...
265
+ https://docs.meilisearch.com/references/stats.html
266
+ Returns
267
+ ----------
268
+ stats: `dict`
269
+ Dictionnary containing stats about the given index.
270
+ """
271
+ return HttpRequests .get (
272
+ self .config ,
273
+ '{}/{}/{}' .format (
274
+ self .index_path ,
275
+ self .uid ,
276
+ self .stat_path ,
277
+ )
278
+ )
0 commit comments