Trying to create a unit test for an elastic search exception handler that uses ResponseException but having trouble setting up the object. Mocking doesn’t work as ResponseException is a final class. produces the following compilation error: Unhandled exception: java.io.IOException Any help is appreciated. Answer Typical Java trick for this case:
Tag: elasticsearch
Bulk upload CSV file into Elasticsearch using JavaAPI
I want to bulk upload the csv file into Elasticsearch using JAVA API (without using logstash). Elasticsearch version – 6.6 I have tried the below program using Jackson format to get source Map for IndexRequest. Because I can’t predefined the POJO variables. So I used dynamic Map from CSV file I got the below exception while running the program When
Multiple Elasticsearch connections in a program
I was working on a service in which I get a searchHit from elastic cluster A and then use a field obtained from A to fetch details from elastic cluster B. I have created a class ClientFactory, which creates ES client based on values that I send. (A’s or B’s) But after getting details from A, I’m not able to
Run ES docker image with custom port using testcontainers
I want to run a container tests that running ES image via Docker. After some research I found https://www.testcontainers.org/ and they also have a built-it ES module. Because my development environment using ES in ports 9200 and 9300 I prefer to use another ports for my tests, let’s say 1200 and 1300. Therefore, to run the docker image from CLI
ElasticSearch – Failed to obtain node locks
I have a single node ElasticSearch Cluster in local. I am unable to start elasticsearch service. Getting this error: I have tried the answers of this and this post but couldn’t resolve. OS: RedHat 7.5 All directories in elasticsearch have write permission There is no other elastic instance running , I have confirmed through ps -ef | grep java Please
How to format a date to insert in Elasticsearch
I’m coding a Java app to insert data in Elasticsearch 7.5.1. When creating the index the property was set like this: Now when inserting the date I’m getting this error: I’m currently doing it like this: And checking a working index I can see it’s formatted like this, example: 2019-10-09T11:11:38.879-04:00 What is the mask to create that format? Answer According
How do I verify that the snapshot is ongoing for a particular index in elastic search?
I have a business need to drop and re-create indices with new mappings. I have been doing that successfully until I encountered the following problem: Cannot delete indices that are being snapshotted. Try again after snapshot finishes or cancel the currently running snapshot. How do I check if the snapshot is ongoing? How do I cancel the currently running snapshot?
How to ensure uniqueness when elasticsearch is inserted in multithreading?
We have some documents of elasticsearch . The uniqueness of the document is determined by some fields together, how to ensure uniqueness when java multi-threading determines whether it exists and is inserted. I didn’t know what good method I had before, so I wrote a method: I guess if it exists, if it doesn’t exist, I insert it, and this
ingest-attachment needs more rights
I have an app which uses the elastic search when I do apt ugrade I get I’m not familiar with java at all. Can you tell me what I’m supposed to do? Answer According to the discussion on elastic.io this is just a warning and by pressing “y” or using the option “-b”, the required permissions are granted. Elastic 7.5
Elasticsearch TransportClient connection [Java]
I am using Elasticsearch in a Java Project using Maven: When I try to initialize a TransportClient in order to index a document it gives me the error: Maybe a need to add more information in config/elasticsearch.yaml about transportartion or the current configuration is wrong. Java code: elasticsearch.yaml: (The other info inside elasticsearch.yaml is commented) localhost:9200 gives me: Answer I