Skip to content

Commit

Permalink
Upgrading Elasticsearch and OpenSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Aug 9, 2024
1 parent 70c90f6 commit a92a61d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import co.elastic.clients.elasticsearch._types.query_dsl.DisMaxQuery;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery;
import co.elastic.clients.elasticsearch.core.CountRequest;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.search.Hit;
Expand Down Expand Up @@ -585,26 +586,30 @@ protected Query fillAttrQuery(
break;

case GE:
query = new Query.Builder().range(QueryBuilders.range().
field(schema.getKey()).gte(JsonData.of(value)).build()).
query = new Query.Builder().range(RangeQuery.of(r -> r.untyped(n -> n.
field(schema.getKey()).
gte(JsonData.of(value))))).
build();
break;

case GT:
query = new Query.Builder().range(QueryBuilders.range().
field(schema.getKey()).gt(JsonData.of(value)).build()).
query = new Query.Builder().range(RangeQuery.of(r -> r.untyped(n -> n.
field(schema.getKey()).
gt(JsonData.of(value))))).
build();
break;

case LE:
query = new Query.Builder().range(QueryBuilders.range().
field(schema.getKey()).lte(JsonData.of(value)).build()).
query = new Query.Builder().range(RangeQuery.of(r -> r.untyped(n -> n.
field(schema.getKey()).
lte(JsonData.of(value))))).
build();
break;

case LT:
query = new Query.Builder().range(QueryBuilders.range().
field(schema.getKey()).lt(JsonData.of(value)).build()).
query = new Query.Builder().range(RangeQuery.of(r -> r.untyped(n -> n.
field(schema.getKey()).
lt(JsonData.of(value))))).
build();
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery;
import co.elastic.clients.elasticsearch._types.query_dsl.TextQueryType;
import co.elastic.clients.elasticsearch.core.CountRequest;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.json.JsonData;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -110,16 +110,16 @@ protected Query getQuery(
}

if (before != null) {
queries.add(new Query.Builder().
range(QueryBuilders.range().
field("instant").lte(JsonData.of(before.toInstant().toEpochMilli())).build()).
queries.add(new Query.Builder().range(RangeQuery.of(r -> r.number(n -> n.
field("instant").
lte((Double.valueOf(before.toInstant().toEpochMilli())))))).
build());
}

if (after != null) {
queries.add(new Query.Builder().
range(QueryBuilders.range().
field("instant").gte(JsonData.of(after.toInstant().toEpochMilli())).build()).
queries.add(new Query.Builder().range(RangeQuery.of(r -> r.number(n -> n.
field("instant").
gte((Double.valueOf(after.toInstant().toEpochMilli())))))).
build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class ElasticsearchRealmDAO extends JPARealmDAO {
protected static final List<SortOptions> ES_SORT_OPTIONS_REALM = List.of(
new SortOptions.Builder().
script(s -> s.type(ScriptSortType.Number).
script(t -> t.inline(i -> i.lang(ScriptLanguage.Painless).
source("doc['fullPath'].value.chars().filter(ch -> ch == '/').count()"))).
script(t -> t.lang(ScriptLanguage.Painless).
source("doc['fullPath'].value.chars().filter(ch -> ch == '/').count()")).
order(SortOrder.Asc)).
build());

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ under the License.

<slf4j.version>1.7.36</slf4j.version>

<elasticsearch.version>8.14.3</elasticsearch.version>
<opensearch.version>2.15.0</opensearch.version>
<elasticsearch.version>8.15.0</elasticsearch.version>
<opensearch.version>2.16.0</opensearch.version>
<opensearch-java.version>2.13.0</opensearch-java.version>

<log4j2.version>2.22.0</log4j2.version>
Expand Down

0 comments on commit a92a61d

Please sign in to comment.