从golang服务器到ES的ES查询返回错误,而直接向ES的邮递员请求则返回预期结果

This is the request body that I for this endpoint using Postman localhost:9201/response_v2_862875ee3a88a6d09c95bdbda029ce2b/_search

{
"_source": ["_id"],
"from": 1,
"size": 10,
: {
                                "should": {
                                    "match": {

            }
        }, {
            "range": {
                "_updated_at": {
                    "from": "36163",
                    "include_lower": true,
                    "include_upper": true,
                    "to": null
                }
            }
        }]
    }
}
}

To this url localhost:9201/rensedbda029ce2b/_search

And I get the results https://gist.gith

But when I make the same request from my server to ES I get an error saying "elastic: Error 400 (Bad Request): Expected [START_OBJECT] but found [START_ARRAY] [type=parsing_exception]"

These are some snippets of my code. I get the query from another util function and use that while making the call to ES.

This is the call to ES res, err = r.esConn.Search(indexName).e(requestBody.ResponsePageLength).Do(ctx)

and the query builder function is this, it takes arguments which are extracted from the body of the request to my server and builds a query based on that.

func CreateMonitoringPipeline(maxResponseTime string, responseQueries []ResponseQuery, baselineFormId string) *elastic.BoolQuery {
finalQuery := elastic.NewBoolQuery()

    dateRangeMatchQuery := elastic.NewRangeQuery("_updated_at").
        Gte(maxResponseTime)

    finalQuery.Filter(dateRangeMatchQuery)
}

return finalQuery
}

I can't figure out why is this happening? my ES is running using the ES binary and my server runs in a docker container.

Completely new to ES and golang so please help.

UPDATE:

This is what I got when I logged my request using SetTraceLog

| ELASTICPOST /resp8ecf8427e/_search HTTP/1.1
| Host: 172.17.0.1:9201
| User-Agent: elastic/5.0.81 (linux-amd64)
| Transfer-Encoding: chunked
| Accept: application/json
| Content-Type: application/json
| Accept-Encoding: gzip
| 
| 7
| ["_id"]
| 0

I can't understand what do the 7 and ["_id"] mean. Is this my request body that ES received?

Thanks for uploading the logs, you are right that the ["_id"] is the request being sent. The problem is in the request line as Source([]string{"_id"}) does not set the source field to ["_id"] as you intended but instead:

Source allows the user to set the request body manually without using any of the structs and interfaces in Elastic.

https://godoc.org/github.com/olivere/elastic#SearchService.Source

You want to use FetchSourceContext instead:

res, err = r.esConn.Search(indexName).From(requestBody.MaxResponseTimestampCount).FetchSourceContext(elastic.NewFetchSourceContect(true). Include("_id")).Query(query).Size(requestBody.ResponsePageLength).Do(ctx)

https://godoc.org/github.com/olivere/elastic#SearchService.FetchSourceContext