Skip to content

UNOMI-901: Upgrade elasticsearch client#729

Merged
jsinovassin merged 10 commits intomasterfrom
upgrade-es-client
Sep 15, 2025
Merged

UNOMI-901: Upgrade elasticsearch client#729
jsinovassin merged 10 commits intomasterfrom
upgrade-es-client

Conversation

@jsinovassin
Copy link
Contributor

@jsinovassin jsinovassin commented Sep 9, 2025

This pull request introduces several notable improvements and updates across the codebase, primarily focusing on support for Elasticsearch 9, and documentation enhancements. The most significant changes include the addition of new dependencies for Elasticsearch 9, updates of the test snapshots, and the removal of deprecated API methods. There are also minor improvements to JavaDoc formatting and test adjustments.

Elasticsearch 9 Support and Dependency Updates:

  • Added new dependencies for unomi-persistence-elasticsearch-core in bom/artifacts/pom.xml and updated the corresponding dependency in kar/pom.xml to enable Elasticsearch 9 support.
  • Updated bom/pom.xml to add dependencies for the new Elasticsearch Java client (elasticsearch-java) and to ensure compatibility by specifying both old and new Elasticsearch versions for different modules.
  • Upgraded the elasticsearch-maven-plugin version in itests/pom.xml for improved compatibility.

Test and Snapshot Updates:

  • Updated test logic and documentation in itests/README.md and related test files to use snapshot_2 instead of the older snapshot_1.6.x, reflecting a newer baseline for migration testing.

API and Codebase Clean-up:

  • Removal of deprecated methods and of unused methods

Documentation:

Minor Code Improvements:

  • Simplified Java code by using diamond operator (<>) for generics in Condition.java.
  • Minor documentation and whitespace clean-up in various POM and Java files.
  • Removal of configuration related to monthly indices, rollover configuration should be used now

These changes collectively modernize the project’s dependencies, improve migration test robustness, and enhance code maintainability and documentation clarity.

@jsinovassin jsinovassin force-pushed the upgrade-es-client branch 2 times, most recently from 51c2d8b to 065c931 Compare September 12, 2025 08:32
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.12.7</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already present Unomi BOM and version in Unomi Parent pom.xml, version is not needed.
Also dependencies are grouped with a logic :

  • unomi modules dependencies are on top
  • embedded dependencies are grouped after
  • provided dependencies then
  • test dependencies finally.
    It's better to move each dependency accordingly to keep an easier reading approach.

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guava version is already setup in the BOM so version is not needed here.
It is also included in the feature so it should be flagged as provided.
Anyway, Guava is a huge dependency we tried to remove in other project/module.
If another option is possible, it's better to remove guava. I don't see direct usage but maybe a library is using it...

<artifactId>hazelcast-all</artifactId>
<version>3.12.8</version>
<scope>provided</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try to remove hazelcast dependency.
Maybe with ES 9 client it is no more needed. If yes, remove it but also from BOM and parent.

itests/pom.xml Outdated
<path.repo>${project.build.directory}/snapshots_repository</path.repo>
<cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
<http.cors.allow-origin>*</http.cors.allow-origin>
<!--http.cors.allow-origin>*</http.cors.allow-origin-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it commented for test or because it is no more needed.
Maybe we can remove it if no more needed.

try {
Map<String, Object> pastEvent = ((List<Map<String, Object>>)testEvent.getProfile().getSystemProperties().get("pastEvents")).stream().filter(profilePastEvent -> profilePastEvent.get("key").equals(pastEventCondition.getParameterValues().get("generatedPropertyKey"))).findFirst().get();
Assert.assertEquals("Profile should have 2 events in the scoring", 2, (long) pastEvent.get("count"));
Assert. assertEquals("Profile should have 2 events in the scoring", 2, (long) pastEvent.get("count"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that space is not wanted

<groupId>org.apache.unomi</groupId>
<artifactId>unomi-metrics</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unomi module dependencies should be placed on top of dependency section and version is not necessary because included by BOM, if not, add module in BOM to avoid specifying version here.

<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can remove hazelcast from here too.

}

private void appendFilderIfPropExist(List<QueryBuilder> queryBuilders, Condition condition, String prop){
private void appendFilderIfPropExist(List<Query> queryBuilders, Condition condition, String prop) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe queryBuilders could be renamed queries as now there is no more QueryBuilder.

for (String prop : new String[]{"id", "path", "scope", "type"}){
public Query buildQuery(Condition condition, Map<String, Object> context, ConditionESQueryBuilderDispatcher dispatcher) {
List<Query> queryBuilders = new ArrayList<Query>();
for (String prop : new String[]{"id", "path", "scope", "type"}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same renaming here queryBuilders -> queries

for (QueryBuilder queryBuilder : queryBuilders) {
BoolQuery.Builder boolQueryBuilder = new BoolQuery.Builder();
for (Query queryBuilder : queryBuilders) {
boolQueryBuilder.must(queryBuilder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and queryBuilder -> query

@jsinovassin jsinovassin merged commit d3d2d16 into master Sep 15, 2025
5 checks passed
@jsinovassin jsinovassin deleted the upgrade-es-client branch September 15, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants