Exemplo n.º 1
0
 def generate_samples(self,
                      beginning: str,
                      samples_num: int = 10) -> List[str]:
     es = utils.get_elastic_engine()
     return es.get(index_name=self.index_name,
                   phrase=beginning,
                   count=samples_num)
Exemplo n.º 2
0
 def get_indices_stats(cls,
                       index_name: str = 't9-index-*') -> Dict[str, Any]:
     es = utils.get_elastic_engine()
     return {
         index_name: {
             'doc_count': stat['primaries']['docs']['count'],
             'size': stat['primaries']['store']['size']
         }
         for index_name, stat in es.get_indices_stats(
             index_name=index_name).items()
     }
Exemplo n.º 3
0
 def delete_index(self):
     es = utils.get_elastic_engine()
     es.delete_index(index_name=self.index_name)
Exemplo n.º 4
0
 def update_index(self, train_sentences: Iterable[str]):
     es = utils.get_elastic_engine()
     es.add_many(index_name=self.index_name, sentences=train_sentences)
Exemplo n.º 5
0
 def create_index(self):
     es = utils.get_elastic_engine()
     es.add_index(name=self.index_name,
                  number_of_shards=Config.ELASTIC_SHARDS_NUMBER,
                  number_of_replicas=Config.ELASTIC_REPLICAS_NUMBER)