mirror of
https://github.com/simon987/Simple-Incremental-Search-Tool.git
synced 2025-12-14 15:49:04 +00:00
Basic indexing + thumbnail is pretty much done
This commit is contained in:
25
search.py
25
search.py
@@ -1,6 +1,7 @@
|
||||
import elasticsearch
|
||||
from elasticsearch import helpers
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
class Search:
|
||||
@@ -22,3 +23,27 @@ class Search:
|
||||
"query": {"term": {"directory": dir_id}}},
|
||||
index=self.index_name)
|
||||
|
||||
def get_index_size(self):
|
||||
|
||||
try:
|
||||
info = requests.get("http://localhost:9200/" + self.index_name + "/_stats")
|
||||
|
||||
if info.status_code == 200:
|
||||
|
||||
parsed_info = json.loads(info.text)
|
||||
|
||||
return int(parsed_info["indices"][self.index_name]["primaries"]["store"]["size_in_bytes"])
|
||||
except:
|
||||
return 0
|
||||
|
||||
def get_doc_count(self):
|
||||
|
||||
try:
|
||||
info = requests.get("http://localhost:9200/" + self.index_name + "/_stats")
|
||||
|
||||
if info.status_code == 200:
|
||||
parsed_info = json.loads(info.text)
|
||||
|
||||
return int(parsed_info["indices"][self.index_name]["primaries"]["indexing"]["index_total"])
|
||||
except:
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user