I use olivere elastic library to connect to elastic. So I have one client, connect with it, add a few documents. Then I have another client that make search. But I have to wait about seconds cause immediate response is empty
_, err := client.Index().
Index(elasticTemplateName).
Type(elasticType).
Id(myID).
BodyJson(myJson).
Do(ctx)
require.NoError(t, err)
// wait cause of async elastic client
time.Sleep(1000 * time.Millisecond)
result, err := anotherClient.Search().Index(IndexName).SearchSource(searchSource).Do(ctx)
another client:
client, err := elastic.NewClient(
elastic.SetURL(
conf.Hosts...
),
elastic.SetSniff(false),
)