Expected [SRART_OBJECT] but found [START_ARRAY]


I'm using python to connect to elastic as following:

import urllib3

from elasticsearch import Elasticsearch

from elasticsearch.connection import create_ssl_context

import configparser


def get_es_session(es_user, es_password, es_host, es_port):


    ssl_context = create_ssl_context()

    ssl_context.check_hostname = False

    ssl_context.verify_mode = False

    es_session = Elasticsearch(

        hosts=[{'host': es_host, 'port': es_port}],



        http_auth=(es_user, es_password))

    return es_session

Then I'm trying to do the simplest search but getting the error above (Expected [SRART_OBJECT] but found [START_ARRAY]):

es_session = get_es_session(es_user, es_password, es_host, es_port)


        #Init scroll by search

        res = es_session.search(index='digital-dashboard*',







The body I'm passing is minimal as it can get:


    "query": {

        "bool": {

            "filter": {

                "range": { "@timestamp": { "gt": "2021-07-12T13:28:54.297000" } }





I even tried passing it as json and not a dictionary using json.dumps but nothing seems to work.
Any ideas will be much much appreciated.

The body looks good. What wonders me, is your error message of an array starting. As the body you showed does not contain any arrays. Are you sure that this is the body that gets sent?

You can use TRACE logging to show what data gets sent to the server, see Python Elasticsearch Client — Elasticsearch 7.13.3 documentation

It happens for every body I'm sending.
I even sent: {"query": {"match_all": {}}})
So clearly there is a deeper problem I can't understand.

As already advised, please use the trace logging above and share the output.

Well I'll try doing that.
There is hardly a proper example on how to enable the trace so I'll look it up and see.

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