Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Spring Boot 2.5.2 #15633

Merged
merged 28 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1359643
Temporarily use personal repository for tests
jdubois Jul 9, 2021
bc492b6
Update to Spring Boot 2.5.2
jdubois Jul 9, 2021
0f1f37a
Update to the latest Elasticsearch version
jdubois Jul 9, 2021
7e9dee3
Update Cassandra dependencies
jdubois Jul 9, 2021
0f08701
Update Elasticsearch in the KNative tests
jdubois Jul 9, 2021
0009dee
Remove unused imports
jdubois Jul 9, 2021
4539f34
Follow @DanielFran recommendation on this
jdubois Jul 9, 2021
25f1acb
Re-implement the search() method in the Repository (pagination isn't …
jdubois Jul 9, 2021
a2518b2
Search repository returns a Page when pagination is selected
jdubois Jul 12, 2021
fb27927
Fix integration tests with the new search repositories
jdubois Jul 12, 2021
b1e62d4
Fix reactive user search repository
jdubois Jul 12, 2021
026a2b0
Revert "Fix integration tests with the new search repositories"
jdubois Jul 12, 2021
21ba0d6
Fix integration tests
jdubois Jul 12, 2021
a90f34a
Fix Openshift snapshot with Elasticsearch
jdubois Jul 12, 2021
55c340b
Update Spring Data Elasticsearch API
jdubois Jul 12, 2021
d900011
Update Elasticsearch version for all integration tests snapshots
jdubois Jul 12, 2021
3c4ee62
force build
jdubois Jul 12, 2021
f11ab05
force build
jdubois Jul 13, 2021
3cd60ca
Configure Spring Data Elasticsearch when Spring Webflux is used
jdubois Jul 13, 2021
32de36d
Fix Spring Boot configuration when using Elasticsearch in dev mode
jdubois Jul 13, 2021
e628b43
Use a NativeSearchQuery and not a StringQuery
jdubois Jul 13, 2021
727dccc
fix variable name
jdubois Jul 13, 2021
74c38f0
Add a wait for Elasticsearch (hoping this is what makes the integrati…
jdubois Jul 13, 2021
671801e
Update generators/server/index.js
mshima Jul 13, 2021
c85b277
Update generators/entity-server/templates/src/main/java/package/repos…
jdubois Jul 13, 2021
734e141
Improve Docker Compose configuration for Elasticsearch
jdubois Jul 13, 2021
2da6777
Fix lint issue
jdubois Jul 13, 2021
8729c2a
Revert "Temporarily use personal repository for tests"
jdubois Jul 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ inputs:
jhipster-bom-repository:
description: 'JHipster BOM repository'
required: false
default: https://github.com/jhipster/jhipster-bom.git
default: https://github.com/jdubois/jhipster-bom.git
jdubois marked this conversation as resolved.
Show resolved Hide resolved
jhipster-bom-branch:
description: 'JHipster BOM branch'
required: false
default: auto
default: patch-spring-boot-2.5.2
jhipster-bom-directory:
description: 'JHipster BOM path'
required: false
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
vmImage: 'ubuntu-20.04'
variables:
# if JHI_LIB_BRANCH value is release, use the release from Maven
JHI_LIB_REPO: https://github.com/jhipster/jhipster-bom.git
JHI_LIB_BRANCH: main
JHI_LIB_REPO: https://github.com/jdubois/jhipster-bom.git
JHI_LIB_BRANCH: patch-spring-boot-2.5.2
# if JHI_GEN_BRANCH value is release, use the release from NPM
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const entityToDtoReference = mapper + '::' + 'toDto'; %>
<%_ if (!reactive) { _%>
<%_ if (searchEngineElasticsearch) { _%>
return StreamSupport
.stream(<%= entityInstance %>SearchRepository.search(queryStringQuery(query)).spliterator(), false)
.stream(<%= entityInstance %>SearchRepository.search(query).spliterator(), false)
<%_ } else { _%>
return <%= entityInstance %>Repository.search(<%= entityClass %>.PREFIX, query)<% if (!dtoMapstruct) { %>;<% } else { %>.stream()<% } %>
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (paginationNo) { %>
<%_ if (viaService) { _%>
Page<<%= instanceType %>> page = <%= entityInstance %>Service.search(query, pageable);
<%_ } else { _%>
Page<<%= persistClass %>> page = <%= entityInstance %><% if (searchEngineElasticsearch) { %>Search<% } %>Repository.search(<% if (searchEngineElasticsearch) { %>queryStringQuery(query)<% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable);
Page<<%= persistClass %>> page = <%= entityInstance %><% if (searchEngineElasticsearch) { %>Search<% } %>Repository.search(<% if (searchEngineElasticsearch) { %>query<% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable);
<%_ } _%>
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(<% if (!reactive) { %>ServletUriComponentsBuilder.fromCurrentRequest()<% } else { %>UriComponentsBuilder.fromHttpRequest(request)<% } %>, page);
return ResponseEntity.ok().headers(headers).body(<% if (!viaService && dtoMapstruct) { %><%= entityListToDtoListReference %>(<% } %>page.getContent()<% if (!viaService && dtoMapstruct) { %>)<% } %>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,40 @@
package <%= packageName %>.repository.search;

import <%= packageName %>.domain.<%= persistClass %>;
<%_ if (reactive) { _%>
<%_ if (!paginationNo) { _%>

<%_ if (!paginationNo) { _%>
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
jdubois marked this conversation as resolved.
Show resolved Hide resolved
import org.springframework.data.domain.Pageable;
<%_ } _%>
<%_ } _%>
<%_ if (reactive) { _%>
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
<%_ } else { _%>
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
<%_ } _%>
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.<% if (reactive) {%>Reactive<% } %>ElasticsearchRepository;

<%_ if (reactive) { _%>
import reactor.core.publisher.Flux;
<%_ } else { _%>
import java.util.stream.Stream;
<%_ } _%>
<%_ if (primaryKey.typeUUID) { _%>

import java.util.UUID;
<% } %>
<%_ if (reactive) { _%>

import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
<%_ } _%>

/**
* Spring Data Elasticsearch repository for the {@link <%= persistClass %>} entity.
*/
public interface <%= entityClass %>SearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= persistClass %>, <%= primaryKey.type %>><% if (reactive) {%>, <%= entityClass %>SearchRepositoryInternal<% } %> {
public interface <%= entityClass %>SearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= persistClass %>, <%= primaryKey.type %>>, <%= entityClass %>SearchRepositoryInternal {
}
<%_ if (reactive) { _%>

Expand All @@ -70,4 +79,44 @@ class <%= entityClass %>SearchRepositoryInternalImpl implements <%= entityClass
.map(SearchHit::getContent);
}
}
<%_ } else { _%>

interface <%= entityClass %>SearchRepositoryInternal {
<%_ if (paginationNo) { _%>
Stream<<%= entityClass %>> search(String query);
<%_ } else { _%>
Page<<%= entityClass %>> search(String query, Pageable pageable);
<%_ } _%>
}

class <%= entityClass %>SearchRepositoryInternalImpl implements <%= entityClass %>SearchRepositoryInternal {

private final ElasticsearchRestTemplate elasticsearchTemplate;

<%= entityClass %>SearchRepositoryInternalImpl(ElasticsearchRestTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}

<%_ if (paginationNo) { _%>
@Override
public Stream<<%= entityClass %>> search(String query) {
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryStringQuery(query));
return elasticsearchTemplate
.search(nativeSearchQuery, <%= entityClass %>.class)
.map(SearchHit::getContent)
.stream();
}
<%_ } else { _%>
@Override
public Page<<%= entityClass %>> search(String query, Pageable pageable) {
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryStringQuery(query));
nativeSearchQuery.setPageable(pageable);
List<<%= entityClass %>> hits = elasticsearchTemplate.search(nativeSearchQuery, <%= entityClass %>.class).map(SearchHit::getContent)
.stream()
.collect(Collectors.toList());

return new PageImpl<>(hits, pageable, hits.size());
}
<%_ } _%>
}
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class <%= serviceClassName %><% if (serviceImpl) { %> implements <%= enti
log.debug("Request to search <%= entityClassPlural %> for query {}", query);<%- include('../../common/search_stream_template', {viaService: false, fromResource: false}); -%>
<%_ } else { _%>
log.debug("Request to search for a page of <%= entityClassPlural %> for query {}", query);
return <%= entityInstance %><% if (searchEngineElasticsearch) { %>Search<% } %>Repository.search(<% if (searchEngineElasticsearch) { %><%= reactive ? 'query' : 'queryStringQuery(query)' %><% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable)<%_ if (!dtoMapstruct) { _%>;<% } else { %>
return <%= entityInstance %><% if (searchEngineElasticsearch) { %>Search<% } %>Repository.search(<% if (searchEngineElasticsearch) { %>query<% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable)<%_ if (!dtoMapstruct) { _%>;<% } else { %>
.map(<%= entityToDtoReference %>);
<%_ } } _%>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ import java.util.ArrayList;
<%_ } _%>
<%_ if (searchEngineElasticsearch && !reactive) { _%>
import java.util.Collections;
<%_ if (paginationNo) { _%>
import java.util.stream.Stream;
<%_ } _%>
<%_ } _%>
import java.util.List;
<%_ if (fieldsContainUUID || primaryKey.typeString || otherEntityPrimaryKeyTypesIncludesUUID) { _%>
Expand All @@ -192,9 +195,6 @@ import static <%= packageName %>.web.rest.TestUtil.sameNumber;
import static <%= packageName %>.web.rest.TestUtil.sameInstant;
<%_ } _%>
import static org.assertj.core.api.Assertions.assertThat;
<%_ if (searchEngineElasticsearch && !reactive) { _%>
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
<%_ } _%>
import static org.hamcrest.Matchers.hasItem;
<%_ if (reactive) { _%>
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -1729,11 +1729,11 @@ _%>
.thenReturn(Flux.just(<%= persistInstance %>));
<%_ } else { _%>
<%_ if (!paginationNo) { _%>
when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()), PageRequest.of(0, 20)))
when(mock<%= entityClass %>SearchRepository.search("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>(), PageRequest.of(0, 20)))
.thenReturn(new PageImpl<>(Collections.singletonList(<%= persistInstance %>), PageRequest.of(0, 1), 1));
<%_ } else { _%>
when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>())))
.thenReturn(Collections.singletonList(<%= persistInstance %>));
when(mock<%= entityClass %>SearchRepository.search("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()))
.thenReturn(Stream.of(<%= persistInstance %>));
<%_ } _%>
<%_ } _%>
<%_ } else if (searchEngineCouchbase) { _%>
Expand Down
4 changes: 2 additions & 2 deletions generators/generator-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const JIB_VERSION = '3.1.1';
// Libraries version
const JHIPSTER_DEPENDENCIES_VERSION = '7.1.1-SNAPSHOT';
// The spring-boot version should match the one managed by https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/JHIPSTER_DEPENDENCIES_VERSION
const SPRING_BOOT_VERSION = '2.4.7';
const SPRING_BOOT_VERSION = '2.5.2';
const LIQUIBASE_VERSION = '4.3.5';
const LIQUIBASE_DTD_VERSION = LIQUIBASE_VERSION.split('.', 3).slice(0, 2).join('.');
const HIBERNATE_VERSION = '5.4.32.Final';
Expand All @@ -61,7 +61,7 @@ const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:4.2021.0
const DOCKER_MEMCACHED = 'memcached:1.6.9-alpine';
const DOCKER_REDIS = 'redis:6.2.4';
const DOCKER_KEYCLOAK = 'jboss/keycloak:14.0.0'; // The version should match the attribute 'keycloakVersion' from /docker-compose/templates/realm-config/jhipster-realm.json.ejs and /server/templates/src/main/docker/config/realm-config/jhipster-realm.json.ejs
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:7.9.3'; // The version should be coherent with the one from spring-data-elasticsearch project
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:7.13.3'; // The version should be coherent with the one from spring-data-elasticsearch project
const DOCKER_KAFKA = `confluentinc/cp-kafka:${KAFKA_VERSION}`;
const DOCKER_ZOOKEEPER = `confluentinc/cp-zookeeper:${KAFKA_VERSION}`;
const DOCKER_SONAR = 'sonarqube:8.9.1-community';
Expand Down
4 changes: 4 additions & 0 deletions generators/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const statistics = require('../statistics');
const { getBase64Secret, getRandomHex } = require('../utils');
const { defaultConfig } = require('../generator-defaults');
const { GRADLE } = require('../../jdl/jhipster/build-tool-types');
const { ELASTICSEARCH } = require('../../jdl/jhipster/search-engine-types');

let useBlueprints;

Expand Down Expand Up @@ -415,6 +416,9 @@ module.exports = class JHipsterServerGenerator extends BaseBlueprintGenerator {
scriptsStorage.set('docker:db:up', `echo "Docker for db ${databaseType} not configured for application ${this.baseName}"`);
}
}
if (this.jhipsterConfig.searchEngine === ELASTICSEARCH) {
dockerAwaitScripts.push('echo "Waiting for Elasticsearch to start" && wait-on "http-get://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s" && echo "Elasticsearch started"');
}

const dockerOthersUp = [];
const dockerOthersDown = [];
Expand Down
2 changes: 1 addition & 1 deletion generators/server/templates/gradle.properties.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jaxbRuntimeVersion=2.3.3
<%_ if (databaseType === 'cassandra') { _%>
# The cassandra driver version should match the one managed by
# https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/<%= SPRING_BOOT_VERSION %>
cassandraDriverVersion=4.9.0
cassandraDriverVersion=4.11.2
<%_ } _%>

# gradle plugin version
Expand Down
2 changes: 1 addition & 1 deletion generators/server/templates/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<%_ if (databaseType === 'cassandra') { _%>
<!-- The cassandra driver version should match the one managed by
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} -->
<cassandra-driver.version>4.9.0</cassandra-driver.version>
<cassandra-driver.version>4.11.2</cassandra-driver.version>
<%_ } _%>
<archunit-junit5.version>0.19.0</archunit-junit5.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>
Expand Down
4 changes: 4 additions & 0 deletions generators/server/templates/src/main/docker/app.yml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ services:
- JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
<%_ } _%>
<%_ if (searchEngine === 'elasticsearch') { _%>
<%_ if (!reactive) { _%>
- SPRING_ELASTICSEARCH_REST_URIS=http://<%= baseName.toLowerCase() %>-elasticsearch:9200
<%_ } else { _%>
- SPRING_DATA_ELASTICSEARCH_CLIENT_REACTIVE_ENDPOINTS=<%= baseName.toLowerCase() %>-elasticsearch:9200
<%_ } _%>
<%_ } _%>
<%_ if (messageBroker === 'kafka') { _%>
- KAFKA_BOOTSTRAPSERVERS=kafka:9092
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ package <%= packageName %>.config;
import com.datastax.oss.driver.api.core.data.TupleValue;
import com.datastax.oss.driver.api.core.type.DataTypes;
import com.datastax.oss.driver.api.core.type.TupleType;
import tech.jhipster.config.JHipsterConstants;
<%_ if (applicationType === 'gateway' && databaseType !== 'cassandra') { _%>
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
<%_ } _%>
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.cassandra.core.convert.CassandraCustomConversions;
import org.springframework.data.convert.ReadingConverter;
Expand Down Expand Up @@ -64,7 +62,7 @@ public class DatabaseConfiguration {

@WritingConverter
class ZonedDateTimeToTupleConverter implements Converter<ZonedDateTime, TupleValue> {
private TupleType type = DataTypes.tupleOf(DataTypes.TIMESTAMP, DataTypes.ASCII);
private TupleType type = DataTypes.tupleOf(DataTypes.TIMESTAMP, DataTypes.TEXT);

@Override
public TupleValue convert(@Nonnull ZonedDateTime source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPe
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity;
<%_ } _%>

Expand Down Expand Up @@ -153,7 +154,7 @@ class CustomElasticsearchPersistentProperty extends SimpleElasticsearchPersisten

@SuppressWarnings({"unchecked"})
public CustomElasticsearchPersistentProperty(Property property, PersistentEntity owner, SimpleTypeHolder simpleTypeHolder) {
super(property, owner, simpleTypeHolder);
super(property, owner, simpleTypeHolder, PropertyNameFieldNamingStrategy.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ package <%= packageName %>.repository.search;
import <%= packageName %>.domain.<%= asEntity('User') %>;
<%_ if (reactive) { _%>
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
<%_ } else { _%>
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
<%_ } _%>
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.data.elasticsearch.repository.<% if (reactive) {%>Reactive<% } %>ElasticsearchRepository;

<%_ if (reactive) { _%>
import reactor.core.publisher.Flux;
<%_ } else { _%>
import java.util.stream.Stream;
<%_ } _%>
<%_ if (databaseType === 'cassandra') { _%>

import java.util.UUID;
<%_ } _%>
<%_ if (reactive) { _%>

import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
<%_ } _%>


/**
* Spring Data Elasticsearch repository for the User entity.
*/
public interface UserSearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= asEntity('User') %>, <% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } %><% if (['cassandra', 'mongodb', 'neo4j'].includes(databaseType) || authenticationType === 'oauth2') { %>String<% } %>><% if (reactive) {%>, UserSearchRepositoryInternal<% } %> {
public interface UserSearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= asEntity('User') %>, <% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } %><% if (['cassandra', 'mongodb', 'neo4j'].includes(databaseType) || authenticationType === 'oauth2') { %>String<% } %>>, UserSearchRepositoryInternal {
}
<%_ if (reactive) { _%>

Expand All @@ -59,7 +62,30 @@ class UserSearchRepositoryInternalImpl implements UserSearchRepositoryInternal {
@Override
public Flux<User> search(String query) {
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryStringQuery(query));
return reactiveElasticsearchTemplate.find(nativeSearchQuery, User.class);
return reactiveElasticsearchTemplate.search(nativeSearchQuery, User.class).map(SearchHit::getContent);
}
}
<%_ } else { _%>

interface UserSearchRepositoryInternal {
Stream<User> search(String query);
}

class UserSearchRepositoryInternalImpl implements UserSearchRepositoryInternal {

private final ElasticsearchRestTemplate elasticsearchTemplate;

UserSearchRepositoryInternalImpl(ElasticsearchRestTemplate elasticsearchTemplate) {
this.elasticsearchTemplate = elasticsearchTemplate;
}

@Override
public Stream<User> search(String query) {
NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(queryStringQuery(query));
return elasticsearchTemplate
.search(nativeSearchQuery, User.class)
.map(SearchHit::getContent)
.stream();
}
}
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public class PublicUserResource {
<%_ if (searchEngine === 'elasticsearch') { _%>
<%_ if (!reactive) { _%>
return StreamSupport
.stream(userSearchRepository.search(queryStringQuery(query)).spliterator(), false)
.stream(userSearchRepository.search(query).spliterator(), false)
.map(<%= asDto('User') %>::new)
.collect(Collectors.toList());
<%_ } else { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ spring:
database-platform: tech.jhipster.domain.util.FixedH2Dialect
<%_ } _%>
<%_ } _%>
<%_ if (databaseType === 'mongodb' || databaseType === 'cassandra' || searchEngine === 'elasticsearch') { _%>
<%_ if (databaseType === 'mongodb' || databaseType === 'cassandra' || (searchEngine === 'elasticsearch' && reactive)) { _%>
DanielFran marked this conversation as resolved.
Show resolved Hide resolved
data:
<%_ } _%>
<%_ if (databaseType === 'mongodb') { _%>
Expand All @@ -191,9 +191,16 @@ spring:
local-datacenter: datacenter1
<%_ } _%>
<%_ if (searchEngine === 'elasticsearch') { _%>
<%_ if (reactive) { _%>
elasticsearch:
client:
reactive:
endpoints: localhost:9200
<%_ } else { _%>
elasticsearch:
rest:
uris: http://localhost:9200
<%_ } _%>
<%_ } _%>
<%_ if (databaseType === 'couchbase') { _%>
couchbase:
Expand Down
Loading