Slow search response

I have created a python appilication , to connect with es, there I am doing a document_id search that is list
es = Elasticsearch(
CLOUD_ID,
http_auth=(elastic_user, ELASTIC_PASSWORD)
query = {
"query": {
"bool": {
"must": [
{
"terms": {
"documentId.keyword":document_id
}
}
]
}
}
}
result = es.search(index=ELASTICSEARCH_INDEX, body=query)
I am getting slow response around in 10 sec , for first time when we hit the same query again I am getting the fast response
this making my appilication slow please can suggest to get fast response in first hits

Welcome!

Many factors but if you are seeing that in the context of integration tests, then that's "ok" I think.

Could you share:

  • the exact query you are running? (Please execute it from the dev console)
  • the response (I'd like to see the "took" value) for the 1st call
  • the second response when you execute again

@dadoonet thank you

query = {
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "documentId.keyword":document_id
          }
        }
      ]
    }
  }
        }
es = Elasticsearch(
CLOUD_ID,
http_auth=(elastic_user, ELASTIC_PASSWORD)
result = es.search(index=ELASTICSEARCH_INDEX, body=query)
hits = result['hits']['hits']

search_results = [hit['_source'] for hit in hits]


for i in range(len(search_results)):
            person_names = search_results[i]['personNames']
            parties = search_results[i]['parties']
            fileName = search_results[i]['fileName']
            contractDocumentId=search_results[i]['documentId']
            startDate=search_results[i]['startDate']
            expiryDate=search_results[i]['endDate']
            filesource=search_results[i]['source']
            sourceEmailId=search_results[i]['sourceEmailId']
            sourceDocLink=search_results[i]['sourceDocLink']

#document_id I am passing a list of document_id , currently this is in dev ,list size 0f 20-30 I am passing

Could you answer my questions?

Note that if you have a document id, you should use it as an _id and then call the multiget API.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.