I want to authenticate in elasticsearch using streamlit and to change the query after authentication, depending on the selected values from some dropdowns. How to achieve this?
I tried:
@st.experimental_memo(ttl=600)
def get_es_result(username='user', password='pass'):
es = Elasticsearch(['https://elastic-endpoint/'],
http_auth=(username, password))
return es
But this triggers:
TypeError: can't pickle _thread.lock objects
In the python app I’m calling the above method like:
def app():
st.title('Home')
es = get_es_result()
df = pd.DataFrame()
query = {
"range": {"TimeStamp": {"gte": "now-10d/d", "format": "epoch_millis"}}
}
result = es.search(index="test-index", size=10000, body=
{
"query": query
}
)
How could I cache the authentication to the elasticsearch so that it happens only once and then query the data?