Programming

Accessing a secured Elasticsearch 8.5 instance using Spring Data Elasticsearch 5.0

The problem When starting an Elasticsearch instance in version 8 (the current version being 8.7.0) for the first time, the Elasticsearch server is by default automatically configured with a random generated password and a self signed certificate to secure the connection between clients and the Elasticsearch server. The password and the fingerprint for the certificate are shown in the output of the server on the first start (output truncated for brevity):

Reading different entities from multiple indices with one call using Spring Data Elasticsearch

The problem In Elasticsearch (the the current version at the time of writing this post is 7.12.1) every index holds exactly one type of data. This type is defined by the index mapping which describes the fields of the index and their types. Spring Data Elasticsearch (the current version is 4.2) automatically maps between a Java class – the entity type – with its properties and the data in the Elasticsearch index.

The mystery of the endless Throwable's cause chain shown in the IntelliJ debugger

A Throwable in Java can have a cause which in turn is a Throwable as well. This cause can have a cause and we can have a chain of Throwableobjects which we can follow until a Throwable has no cause. Let me explain this with a small example: 1class Scratch { 2 public static void main(String[] args) { 3 try { 4 try { 5 int division = divide(4, 0); 6 } catch (Exception e) { 7 throw new IllegalArgumentException("got exception calling divide", e); 8 } 9 } catch (Throwable t) { 10 while (t !

show artillery http traffic

Just playing with https://artillery.io/. If you need to see which requests are sent during setting up your test script, set the DEBUG environment variable: DEBUG=http:request,http:response,http:full_body $(npm bin)/artillery run test.yml

Implement a rolling index strategy with Spring Data Elasticsearch 4.1

With the release of version 4.1 Spring Data Elasticsearch now supports the index templates of Elasticsearch. Index templates allow the user to define settings, mappings and aliases for indices that are automatically created by Elasticsearch when documents are saved to a not yet existing index. In this blog post I will show how index templates can be used in combination with Spring Data Repository customizations to implement a rolling index strategy where new indices will be created automatically based on the date.

How to use Elasticsearch's range types with Spring Data Elasticsearch

Elasticsearch allows the data, that is stored in a document, to be not only of elementary types, but also of a range of types, see the documentation. With a short example I will explain this range type and how to use it in Spring Data Elasticsearch (the current version being 4.0.3). For this example we want be able to answer the question: “Who was president of the United States of America in the year X?

Search entities within a geographic distance with Spring Data Elasticsearch 4

A couple of months ago I published the post Using geo-distance sort in Spring Data Elasticsearch 4. In the comments there came up the question “What about searching within a distance?” Well, this is not supported by query derivation from the method name, but it can easily be done with a custom repository implementation (see the documentation for more information about that). I updated the example – which is available on GitHub – and will explain what is needed for this implementation.

mapjfx display problem on Windows 10 seems solved

For some time now there was a bug that the map was not displaying properly on some Windows systems, see mapjfx problems https://github.com/sothawo/mapjfx/issues/36 https://github.com/sothawo/mapjfx/issues/81 It seems this was because of a bug in the WebView from JavaFX https://bugs.openjdk.java.net/browse/JDK-8234471. Thanks to https://github.com/vewert and https://github.com/Abu-Abdullah investigating into this. This issue was fixed with JavaFX15, I tried this on a virtual machine with Windows10 and could not reproduce the error anymore. There is no need to update mapjfx to JavaFX15 (as macOS and *nix are not hit by this bug).

Use an index name defined by the entity to store data in Spring Data Elasticsearch 4.0

When using Spring Data Elasticsearch (I am referencing the current version 4.0.2), normally the name of the index where the documents are stored is taken from the @Document annotation of the entity class – here it’s books: @Document(indexName="books") public class Book { // ... } Recently in a discussion of a Pull Request in Spring Data Elasticsearch, someone told that she needed a possibility to extract the name from the entity itself, as entities might go to different indices.

mapjfx 2.15.0 and 1.33.0 released adding circles and OpenLayers 6.4.2

I just released mapjfx versions 1.33.0 and 2.15.0, they will be available in maven central: <dependency> <groupId>com.sothawo</groupId> <artifactId>mapjfx</artifactId> <version>1.33.0</version> </dependency> <dependency> <groupId>com.sothawo</groupId> <artifactId>mapjfx</artifactId> <version>2.15.0</version> </dependency> 1.33.0 is built using Java 8 and 2.15.0 uses Java 11. Circles can now be added to a map, giving the center coordinates and the radius in meters with custom coloring and transparency, thanks to Hanwoo Kim for this contribution! The OpenLayers version now is 6.