-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to configure an OpenSearch distribution for the Elasticsear…
…ch DevService
- Loading branch information
1 parent
e96b68a
commit 17828c7
Showing
18 changed files
with
488 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...t/hibernate/search/orm/opensearch/devservices/HibernateSearchDevServicesTestResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package io.quarkus.it.hibernate.search.orm.opensearch.devservices; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.transaction.Transactional; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.hibernate.Session; | ||
import org.hibernate.SessionFactory; | ||
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; | ||
import org.hibernate.search.mapper.orm.session.SearchSession; | ||
|
||
@Path("/test/dev-services") | ||
public class HibernateSearchDevServicesTestResource { | ||
|
||
@Inject | ||
SessionFactory sessionFactory; | ||
|
||
@Inject | ||
Session session; | ||
|
||
@Inject | ||
SearchSession searchSession; | ||
|
||
@GET | ||
@Path("/hosts") | ||
@Transactional | ||
@SuppressWarnings("unchecked") | ||
public String hosts() { | ||
return ((List<String>) sessionFactory.getProperties().get("hibernate.search.backend.hosts")).iterator().next(); | ||
} | ||
|
||
@GET | ||
@Path("/schema-management-strategy") | ||
@Transactional | ||
public String schemaManagementStrategy() { | ||
var strategy = ((SchemaManagementStrategyName) sessionFactory.getProperties() | ||
.get("hibernate.search.schema_management.strategy")); | ||
return strategy == null ? null : strategy.externalRepresentation(); | ||
} | ||
|
||
@PUT | ||
@Path("/init-data") | ||
@Transactional | ||
public void initData() { | ||
IndexedEntity entity = new IndexedEntity("John Irving"); | ||
session.persist(entity); | ||
} | ||
|
||
@PUT | ||
@Path("/refresh") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String refresh() { | ||
searchSession.workspace().refresh(); | ||
return "OK"; | ||
} | ||
|
||
@GET | ||
@Path("/count") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public long count() { | ||
return searchSession.search(IndexedEntity.class) | ||
.where(f -> f.matchAll()) | ||
.fetchTotalHitCount(); | ||
} | ||
} |
Oops, something went wrong.