Testing ElasticSearch - Java junit - is it possible to create unit tests?

Is it possible to create inmemory elasticsearch? I want to run tests creating index, inserting documents, searching them with some business logic.. And when Junits start, there is no ElasticSearch index instance on the server. Is it possible to do such test and how? Do you have any examples?

I want to test my real components which after test are deployed on real server and connected to real ElasticSearch instance

It's possible to start an embedded (in-process) ES instance, but IIRC it's no longer supported and will eventually be removed. But you can totally start an ES instance as a separate process. Docker makes this very simple.

(I digress, but it's arguable that when you're relying on an actual ES instance for your tests you're no longer doing unit testing but rather integration testing.)