I'm using olivere's Elasticsearch library for Go - https://github.com/olivere/elastic
I'm not able to properly construct the search query, it keeps returning 0 hits.
termQuery := elasticClient.NewTermQuery("hash", "hashedID")
fmt.Println(termQuery)
searchResult, err := qs.client.Search().Index("someIndex").
Type("node").
Query(termQuery).
Pretty(true).
Do(ctx)
if err != nil {
return nil
}
searchResult.Hits.TotalHits
gives 0 hits even though there is data.
The data is in an Elasticsearch server running on my local machine which I can see if I run a REST API call:
{
"_index": "someIndex",
"_type": "node",
"_id": "hashedID",
"_score": 1,
"_source": {
"node": "test",
"hash": "hashedID",
"active": true
}
How can I fix my Search query?