from pif_compiler.functions.common_log import get_logger
from pif_compiler.functions.db_utils import db_connect

log = get_logger()

def search_ingredient(text):
    col = db_connect(db_name="cir", collection_name="noael")
    col.create_index([("ingrediente", "text")])
    log.info(f"Searching for ingredient in CIR database: {text}")
    risultati = col.find({ "$text": { "$search": text } })
    return list(risultati)
    
    
    
