Nabil Khoufi

14 papers C 2Misc 1Journal 5Unranked 5
YearRankTypeTitle / Venue / Authors
2024 J jnl
Computación y Sistemas (CyS)
Nabil Khoufi, Chafik Aloulou
2024 conf
LPKM
Manel Ben Amira, Nabil Khoufi, Chafik Aloulou
2024 J jnl
Informatica (Slovenia)
Bassem Bsir, Nabil Khoufi, Mounir Zrigui
2023 conf
ICIKS
Seifeddine Mechti, Rim Faiz, Nabil Khoufi, Shaima Antit, Moez Krichen
2021 conf
TACC
Rahma Maalej, Nabil Khoufi, Chafik Aloulou
2018 conf
ISDA (2)
Seifeddine Mechti, Nabil Khoufi, Lamia Hadrich Belguith
2017
Nabil Khoufi
2016 conf
CICLing (1)
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2016 J jnl
Int. J. Speech Technol.
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2016 C conf
SNPD
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2015 J jnl
Res. Comput. Sci.
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2014 C conf
AICCSA
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2014 J jnl
CoRR
Nabil Khoufi, Chafik Aloulou, Lamia Hadrich Belguith
2013 Misc conf
RANLP
Nabil Khoufi, Manel Boudokhane
redb/utils/push_to_elastic.py
← Index redb/utils/push_to_elastic.py python
import json
import os
#from redb.settings import elasticsearch as es
from elasticsearch import Elasticsearch
from dataclasses import asdict
from dotenv import load_dotenv

class Utils():
    """
    Utility class for pushing

    """
    @staticmethod
    def push_to_elastic(sample_dict):
        """
        Pushes the sample_dict to elastic search
        """
        load_dotenv()
        ELASTIC_ENDPOINT = os.getenv("ELASTIC_HOST")
        ELASTIC_ENFORCE_SSL = os.getenv("ELASTIC_ENFORCE_SSL", False) == "True"
        ELASTIC_USER = os.getenv("ELASTIC_USER")
        ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD")
        ELASTIC_BINARIES_COLLECTION = os.getenv(
            "ELASTIC_BINARIES_COLLECTION", "redb_test"
        )
        es = Elasticsearch(
            ELASTIC_ENDPOINT,
            verify_certs=ELASTIC_ENFORCE_SSL,
            basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),
            maxsize=20,
            retry_on_timeout=True,
            timeout=30,
        )

        try:
            dict_dump = json.dumps(sample_dict)
        except Exception as e:
            print(f"Error: {e}")
            return False
        elastic = es.index(index=ELASTIC_BINARIES_COLLECTION, body=dict_dump)
        return True
    
    def push_to_index(sample_dict, index_name):
        """
        Pushes the sample_dict to elastic search
        """
        load_dotenv()
        ELASTIC_ENDPOINT = os.getenv("ELASTIC_HOST")
        ELASTIC_ENFORCE_SSL = os.getenv("ELASTIC_ENFORCE_SSL", False) == "True"
        ELASTIC_USER = os.getenv("ELASTIC_USER")
        ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD")
        ELASTIC_BINARIES_COLLECTION = index_name
        
        es = Elasticsearch(
            ELASTIC_ENDPOINT,
            verify_certs=ELASTIC_ENFORCE_SSL,
            basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),
            maxsize=20,
            retry_on_timeout=True,
            timeout=30,
        )

        try:
            dict_dump = json.dumps(sample_dict)
        except Exception as e:
            print(f"Error: {e}")
            return False
        elastic = es.index(index=ELASTIC_BINARIES_COLLECTION, body=dict_dump)
        return True