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?
monitoringAnswersPipeline = append(monitoringAnswersPipeline, esSubQuery)to go inside the for loop, otherwise it just adds the final esSubQuery rather than all of them.olivere/elasticlibrary which I think you are you can turn on a feature to print the request before it is sent by doing callingSetTraceLogwhen you create the client. godoc.org/github.com/olivere/elastic#SetTraceLog This will print out the actual request you are making so you can compare it with the one you are sending in Postman