How to write unit tests in spring boot for elasticsearch - spring

I have to write unit tests of spring boot application with elasticsearch.
I've read a lot of documentation, and I've discovered that an embedded elasticsearch can be used, a bit like using H2 for DBMS.
Unfortunately, applying what I read and looking at some examples found on the net, I came to the conclusion that an embedded elasticsearch cannot be used for my purpose, or I don't know how to make it work.
Has anyone ever used an embedded elasticsearch to make me understand how he used it?

Related

Testing a Spring Boot Elastic Search application and loading context without starting ES-Instance

Since I updated to Spring boot 2.5 my application context won't start in the Test environment.
We have several test environments. Most tests do not need an Elastic search instance. Those that need it share an Elasticsearch test container instance.
Since the Update the creation of repositories causes some kind of query to Elasticsearch. That fails and causes the context not to load.
Is there a way to mock away the Spring Data Elasticsearch part(Not loading is not really an option to load most parts of the context)?
Should I be starting an Elasticsearch Instance for all integration tests(that seems like a little overkill, since few tests actually need it)?
Any ideas are highly appreciated.

Apache AVRO with Spring boot

Does anyone know hot to use Apache AVRO RPC with Spring boot? Every single AVRO implementation I have seen is hosted on a netty server.
You might be trying to achieve the same thing I'm trying to achieve -- speeding up json serialization with spring boot and spring web. Or maybe you just want to use avro? And my comment is a little late, since it's months after you posted. I have run across this information about using an avro message converter, so thought I would share it with you to see if it helps:
https://docs.spring.io/spring-cloud-stream/docs/Brooklyn.RELEASE/reference/html/contenttypemanagement.html#_schema_based_message_converters
Or did you already find it? If so, can you share whatever solution that you came up with? Our rest json serialization takes much longer than the whole rest of the operation and I would like to speed it up as much as possible.

In-memory elastic search

I have a scenario where I want to query database once and after that want to cache the whole data in memory.
I got the suggestion for in-memory elastic search, I have googled it understand what it is and how can I implement it in my spring boot application, but I didn't find any appropriate solution.
Any suggestion on this like how can I implement this in my spring boot app and what would be the approach.
There used to be an in-memory storage type in Elasticsearch in 1.x, but it has been removed in 2.x and later versions. If your working set is small enough it might be mapped to memory in full, but you cannot really control that other than having enough memory.
If you want to run an embedded / in-process Elasticsearch with your Spring Boot application that feature was removed in 5.x and this blog post explains why.

Spring boot , Elasticsearch

Searched over the net but unable to find the satisfying approach.
I am new to spring boot and aware of starter dependancies,
I want to develop a springboot app using elastic search as a storage system.
Wherever i searched i found that somewhere my service class will have to implement some interface from springframework for ES crud operations.
Is there any other way without implementing or extending the components.
I myself want to create transport client and want to query ES by my code or methods not by overidden ones.
Please if you ahve ever seen any projects you can redirect me to that link .
Thanks.
Assuming I understand you correctly, you can use the Elasticsearch REST client: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
You supply the JSON entities for the queries and parse the responses yourself. Its pretty basic in what it does, so you're not dependent on a lot of third party stuff to perform operations.

Neo4j unmanaged extension with Spring Data

I was advised to develop Neo4j extension because of poor performance due to the many calls to the Neo4j REST interface introduced by Spring Data Neo4j. For the good start I was able to run simply Neo4j extension from Neo4j documentation:
http://docs.neo4j.org/chunked/stable/server-unmanaged-extensions.html
Now I have to move some logic from my web service to Neo4j extension to make communication between them as small as possible. However, my web service is based on Spring Data Neo4j as well as Spring Data JPA, so to reuse my actual code I would like to use also Spring Data in my extension. I have found this documentation:
http://docs.spring.io/spring-data/data-neo4j/docs/current/reference/html/reference_neo4j-server.html
but it is not clear for me and there is no working example. Is there any sample code with such integration?
There is a great example on using SDN in an unmanage extension, see http://inserpio.wordpress.com/2014/04/30/extending-the-neo4j-server-with-spring-data-neo4j/.

Resources