I am using elastic4s for all the elasticsearch operations.
I am trying to test an application in the docker containers (testconatiners)
The test will index 3 documents and retrieves them again and verify. The third document is always null while retrieving. I used a debug point in the code and realised if I wait for couple of seconds before retrieving the document, it retrieves it properly.
Here is the sample code for indexing.
implicit val caseClassNameEncoder: Encoder[CaseClassName] = Encoder.forProduct7(
"field_1", "field_2", "field_3", "field_4", "field_5", "field_6", "field_7"
)(u => (u.field_1.format(dateTimeWithZoneFormatter), u.field_2, u.field_3, u.field_4, u.field_5, u.field_6, u.field_7))
client.execute {
indexInto(writeAlias).id(caseClassName.id.toString).doc(caseClassName.asJson).refreshImmediately
}
I just added waiting time 1 second, the test is success. How do I deal with it?