How to test elasticsearch queries?

I want to test the queries are written in my project. I want to write some integration test which could test the correctness of my queries that I have written. What could be the best way/best practice to do the same?

Hi @siddharthgoel88,

we do this ourselves in the Elasticsearch project and have specific test infrastructure for that. Basically, your test needs to extend from ESIntegTestCase. This test case will start a test cluster in the same JVM where you can add documents via the Java API (just call the client() method to get a client)).

For an example see SearchQueryIT on Github.

Daniel

1 Like