├── version.properties ├── spring-data-opensearch └── src │ ├── test │ ├── resources │ │ ├── mockito-extensions │ │ │ └── org.mockito.plugins.MockMaker │ │ ├── synonyms │ │ │ ├── synonyms.txt │ │ │ ├── mappings.json │ │ │ ├── settings-with-external-file.json │ │ │ └── settings.json │ │ ├── highlights │ │ │ ├── highlights.json │ │ │ └── highlights-with-parameters.json │ │ ├── local-maven-repo │ │ │ └── org │ │ │ │ └── projectlombok │ │ │ │ └── lombok │ │ │ │ ├── 999999 │ │ │ │ ├── lombok-999999.jar.md5 │ │ │ │ ├── lombok-999999.pom.md5 │ │ │ │ ├── lombok-999999.jar.sha1 │ │ │ │ ├── lombok-999999.pom.sha1 │ │ │ │ ├── lombok-999999.jar │ │ │ │ └── lombok-999999.pom │ │ │ │ ├── maven-metadata.xml.md5 │ │ │ │ ├── maven-metadata.xml.sha1 │ │ │ │ └── maven-metadata.xml │ │ ├── org │ │ │ └── springframework │ │ │ │ └── data │ │ │ │ └── elasticsearch │ │ │ │ └── client │ │ │ │ ├── scroll_clean.json │ │ │ │ ├── get-by-id-no-hit.json │ │ │ │ ├── update-ok-deleted.json │ │ │ │ ├── update-ok-updated.json │ │ │ │ ├── index-ok-created.json │ │ │ │ ├── index-ok-updated.json │ │ │ │ ├── search-ok-no-hits.json │ │ │ │ ├── get-by-id-ok.json │ │ │ │ ├── scroll_no_more_results.json │ │ │ │ ├── bulk-ok.json │ │ │ │ ├── aggregate-ok-no-results.json │ │ │ │ ├── update-error-not-found.json │ │ │ │ ├── info.json │ │ │ │ ├── search-ok-single-hit.json │ │ │ │ ├── aggregate-ok-single-result.json │ │ │ │ ├── multi-get-ok-2-hits.json │ │ │ │ ├── aggregate-ok-multiple-results.json │ │ │ │ ├── multi-get-ok-2-hits-1-unavailable.json │ │ │ │ ├── scroll_ok.json │ │ │ │ ├── search-ok-multiple-hits.json │ │ │ │ └── search-ok-scroll.json │ │ ├── mappings │ │ │ ├── test-field-analyzed-mappings.json │ │ │ ├── test-mappings.json │ │ │ ├── test-field-mappings.json │ │ │ ├── test-dynamic_templates_mappings.json │ │ │ └── test-dynamic_templates_mappings_two.json │ │ ├── node-client-configuration.yml │ │ ├── META-INF │ │ │ ├── spring.factories │ │ │ └── beans.xml │ │ ├── settings │ │ │ ├── test-settings.yml │ │ │ ├── test-normalizer.json │ │ │ └── test-settings.json │ │ ├── testcontainers-opensearch.properties │ │ ├── index-template-requests │ │ │ └── put-index-template.json │ │ ├── log4j2.xml │ │ └── logback.xml │ └── java │ │ └── org │ │ ├── springframework │ │ └── data │ │ │ └── elasticsearch │ │ │ ├── config │ │ │ └── notnested │ │ │ │ ├── package-info.java │ │ │ │ ├── SampleElasticsearchRepository.java │ │ │ │ └── SampleUUIDKeyedElasticsearchRepository.java │ │ │ ├── repositories │ │ │ ├── cdi │ │ │ │ ├── package-info.java │ │ │ │ ├── SamplePersonRepositoryCustom.java │ │ │ │ ├── SamplePersonRepositoryImpl.java │ │ │ │ ├── SamplePersonRepository.java │ │ │ │ ├── QualifiedProductRepository.java │ │ │ │ ├── CdiProductRepository.java │ │ │ │ ├── PersonDB.java │ │ │ │ └── OtherQualifier.java │ │ │ ├── complex │ │ │ │ └── custommethod │ │ │ │ │ ├── manualwiring │ │ │ │ │ ├── ComplexElasticsearchRepositoryCustom.java │ │ │ │ │ └── ComplexElasticsearchRepositoryManualWiring.java │ │ │ │ │ └── autowiring │ │ │ │ │ ├── ComplexElasticsearchRepositoryImpl.java │ │ │ │ │ ├── ComplexElasticsearchRepositoryCustom.java │ │ │ │ │ └── ComplexElasticsearchRepository.java │ │ │ └── custommethod │ │ │ │ └── QueryParameter.java │ │ │ ├── junit │ │ │ └── jupiter │ │ │ │ ├── package-info.java │ │ │ │ ├── Tags.java │ │ │ │ ├── ClusterConnectionException.java │ │ │ │ ├── IntegrationtestEnvironment.java │ │ │ │ └── IntegrationTest.java │ │ │ ├── core │ │ │ └── paginating │ │ │ │ └── package-info.java │ │ │ └── utils │ │ │ ├── geohash │ │ │ ├── package-info.java │ │ │ ├── GeometryValidator.java │ │ │ ├── Geometry.java │ │ │ └── ShapeType.java │ │ │ ├── IndexBuilder.java │ │ │ ├── IdGenerator.java │ │ │ ├── IndexInitializer.java │ │ │ └── IndexNameProvider.java │ │ └── opensearch │ │ └── data │ │ └── client │ │ ├── core │ │ ├── index │ │ │ ├── IndexTemplateOSCIntegrationTests.java │ │ │ └── IndexTemplateORHLCIntegrationTests.java │ │ ├── cluster │ │ │ ├── ClusterOperationsOSCIntegrationTests.java │ │ │ ├── ClusterOperationsORHLCIntegrationTests.java │ │ │ └── ClusterOperationsReactiveOSCIntegrationTests.java │ │ ├── routing │ │ │ ├── RoutingOSCIntegrationTests.java │ │ │ └── RoutingORHLCIntegrationTests.java │ │ ├── SourceFilterOSCIntegrationTests.java │ │ ├── SourceFilterORHLCIntegrationTests.java │ │ ├── event │ │ │ ├── CallbackOSCIntegrationTests.java │ │ │ └── CallbackORHLCIntegrationTests.java │ │ ├── query │ │ │ ├── CriteriaQueryOSCIntegrationTests.java │ │ │ └── CriteriaQueryORHLCIntegrationTests.java │ │ ├── ReactiveReindexOSCIntegrationTests.java │ │ ├── indices │ │ │ ├── IndexOperationsOSCIntegrationTests.java │ │ │ └── IndexOperationsORHLCIntegrationTests.java │ │ ├── ReactiveSearchTemplateOSCIntegrationTests.java │ │ ├── geo │ │ │ ├── GeoJsonOSCIntegrationTests.java │ │ │ └── GeoJsonORHLCIntegrationTests.java │ │ ├── paginating │ │ │ ├── SearchAfterOSCIntegrationTests.java │ │ │ └── SearchAfterORHLCIntegrationTests.java │ │ ├── ReactivePointInTimeOSCIntegrationTests.java │ │ ├── ReindexOSCIntegrationTests.java │ │ └── ReindexORHLCIntegrationTests.java │ │ ├── config │ │ ├── AuditingOSCIntegrationTests.java │ │ ├── AuditingORHLCIntegrationTests.java │ │ └── notnested │ │ │ ├── EnableRepositoriesOSCIntegrationTests.java │ │ │ └── EnableRepositoriesORHLCIntegrationTests.java │ │ ├── EnabledIfOpenSearchVersion.java │ │ ├── repositories │ │ ├── dynamicindex │ │ │ ├── DynamicIndexEntityOSCIntegrationTests.java │ │ │ └── DynamicIndexEntityORHLCIntegrationTests.java │ │ ├── spel │ │ │ ├── SpELEntityOSCIntegrationTests.java │ │ │ └── SpELEntityORHLCIntegrationTests.java │ │ ├── geo │ │ │ ├── GeoRepositoryOSCIntegrationTests.java │ │ │ └── GeoRepositoryORHLCIntegrationTests.java │ │ ├── nestedobject │ │ │ ├── InnerObjectOSCIntegrationTests.java │ │ │ └── InnerObjectORHLCIntegrationTests.java │ │ ├── synonym │ │ │ ├── SynonymRepositoryOSCIntegrationTests.java │ │ │ └── SynonymRepositoryORHLCIntegrationTests.java │ │ ├── doubleid │ │ │ ├── DoubleIDRepositoryOSCIntegrationTests.java │ │ │ └── DoubleIDRepositoryORHLCIntegrationTests.java │ │ ├── integer │ │ │ ├── IntegerIDRepositoryOSCIntegrationTests.java │ │ │ └── IntegerIDRepositoryORHLCIntegrationTests.java │ │ ├── uuidkeyed │ │ │ ├── UUIDElasticsearchRepositoryOSCIntegrationTests.java │ │ │ └── UUIDElasticsearchRepositoryORHLCIntegrationTests.java │ │ └── custommethod │ │ │ └── CustomMethodRepositoryOSCIntegrationTests.java │ │ ├── immutable │ │ ├── ImmutableRepositoryOSCIntegrationTests.java │ │ └── ImmutableRepositoryORHLCIntegrationTests.java │ │ └── repository │ │ ├── support │ │ ├── ElasticsearchRepositoryOSCIntegrationTests.java │ │ └── ElasticsearchRepositoryORHLCIntegrationTests.java │ │ └── query │ │ └── valueconverter │ │ ├── ValueConverterOSCIntegrationTests.java │ │ └── ValueConverterORHLIntegrationTests.java │ └── main │ └── java │ └── org │ └── opensearch │ └── data │ ├── client │ ├── orhlc │ │ ├── ScriptField.java │ │ ├── SearchHitsUtil.java │ │ ├── OpenSearchAggregations.java │ │ ├── OpenSearchClusterOperations.java │ │ └── DefaultClusterOperations.java │ └── osc │ │ ├── package-info.java │ │ ├── CriteriaQueryException.java │ │ ├── OpenSearchAggregation.java │ │ ├── EntityAsMap.java │ │ ├── Aggregation.java │ │ └── ReactiveClusterTemplate.java │ └── core │ └── OpenSearchOperations.java ├── .github ├── CODEOWNERS ├── dependabot.yml ├── workflows │ ├── add-untriaged.yml │ └── publish-snapshots.yml └── pull_request_template.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── spring-data-opensearch-testcontainers └── src │ ├── main │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ └── resources │ └── logback-test.xml ├── spring-data-opensearch-docker-compose └── src │ ├── main │ ├── resources │ │ └── META-INF │ │ │ └── spring.factories │ └── java │ │ └── org │ │ └── opensearch │ │ └── spring │ │ └── boot │ │ └── docker │ │ └── compose │ │ └── service │ │ └── connection │ │ └── OpenSearchEnvironment.java │ └── test │ └── resources │ └── org │ └── opensearch │ └── spring │ └── boot │ └── docker │ └── compose │ └── service │ └── connection │ ├── opensearch-compose.yaml │ └── secure-opensearch-compose.yaml ├── CODE_OF_CONDUCT.md ├── spring-data-opensearch-starter └── src │ ├── test │ ├── resources │ │ └── testcontainers-opensearch.properties │ └── java │ │ └── org │ │ └── opensearch │ │ └── spring │ │ └── boot │ │ └── autoconfigure │ │ └── data │ │ ├── entity │ │ ├── ProductOpenSearchRepository.java │ │ ├── ReactiveProductOpenSearchRepository.java │ │ └── Product.java │ │ └── repository │ │ ├── ProductRepository.java │ │ └── ReactiveProductRepository.java │ └── main │ ├── resources │ └── META-INF │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── java │ └── org │ └── opensearch │ └── spring │ └── boot │ └── autoconfigure │ ├── OpenSearchConnectionDetails.java │ ├── OpenSearchRestHighLevelClientAutoConfiguration.java │ ├── data │ ├── ReactiveOpenSearchRepositoriesAutoConfiguration.java │ ├── ReactiveOpenSearchRepositoriesRegistrar.java │ └── OpenSearchDataAutoConfiguration.java │ ├── OpenSearchClientAutoConfiguration.java │ └── ReactiveOpenSearchClientAutoConfiguration.java ├── spring-data-opensearch-examples ├── spring-boot-gradle │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── org │ │ │ └── opensearch │ │ │ └── data │ │ │ └── example │ │ │ ├── MarketplaceApplication.java │ │ │ ├── repository │ │ │ └── MarketplaceRepository.java │ │ │ ├── rest │ │ │ └── MarketplaceRestController.java │ │ │ └── service │ │ │ └── MarketplaceInitializer.java │ │ └── test │ │ └── java │ │ └── org │ │ └── opensearch │ │ └── data │ │ └── example │ │ └── repository │ │ ├── TestMarketplaceApplication.java │ │ └── MarketplaceRepositoryIntegrationTests.java ├── spring-boot-java-client-gradle │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── org │ │ │ └── opensearch │ │ │ └── data │ │ │ └── example │ │ │ ├── MarketplaceApplication.java │ │ │ ├── repository │ │ │ └── MarketplaceRepository.java │ │ │ ├── rest │ │ │ └── MarketplaceRestController.java │ │ │ └── service │ │ │ └── MarketplaceInitializer.java │ │ └── test │ │ └── java │ │ └── org │ │ └── opensearch │ │ └── data │ │ └── example │ │ └── repository │ │ ├── TestMarketplaceApplication.java │ │ └── MarketplaceRepositoryIntegrationTests.java └── spring-boot-reactive-client-gradle │ └── src │ ├── main │ ├── resources │ │ └── application.yml │ └── java │ │ └── org │ │ └── opensearch │ │ └── data │ │ └── example │ │ ├── MarketplaceApplication.java │ │ ├── repository │ │ └── ReactiveMarketplaceRepository.java │ │ └── rest │ │ └── MarketplaceRestController.java │ └── test │ └── java │ └── org │ └── opensearch │ └── data │ └── example │ └── repository │ ├── TestMarketplaceApplication.java │ └── MarketplaceRepositoryIntegrationTests.java ├── NOTICE.txt ├── .gitignore ├── gradle.properties ├── .whitesource ├── spring-data-opensearch-test-autoconfigure └── src │ └── main │ ├── resources │ └── META-INF │ │ └── spring │ │ └── org.opensearch.spring.boot.autoconfigure.test.AutoConfigureDataOpenSearch.imports │ └── java │ └── org │ └── opensearch │ └── spring │ └── boot │ └── autoconfigure │ └── test │ ├── OpenSearchTypeExcludeFilter.java │ ├── DataOpenSearchTestContextBootstrapper.java │ └── AutoConfigureDataOpenSearch.java ├── jenkins └── release.jenkinsFile └── MAINTAINERS.md /version.properties: -------------------------------------------------------------------------------- 1 | version=3.0.0 2 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/synonyms/synonyms.txt: -------------------------------------------------------------------------------- 1 | british,english 2 | queen,monarch 3 | 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This should match the list of maintainers in MAINTAINERS.md 2 | * @reta @dlvenable @andrross 3 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/highlights/highlights.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields": { 3 | "some-field": {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 998d3b8876980a3ef5a90adc982cc727 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensearch-project/spring-data-opensearch/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.md5: -------------------------------------------------------------------------------- 1 | f6bbf833798e7af0055b94865a46440e -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.md5: -------------------------------------------------------------------------------- 1 | 63317ccd46b6663ff35cb142e05dce10 -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | f4090a49c6eec680c075130b68bf8ee48aac4e94 -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.sha1: -------------------------------------------------------------------------------- 1 | 59ddfc2b714be7918808eacecc5739b8d277e60e -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.sha1: -------------------------------------------------------------------------------- 1 | db353983c68ade94ae7e08acfacc0fc21ed8b64b -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gradle" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/scroll_clean.json: -------------------------------------------------------------------------------- 1 | { 2 | "num_freed": 1, 3 | "succeeded": true 4 | } 5 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mappings/test-field-analyzed-mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string", 3 | "analyzer": "standard_lowercase_asciifolding" 4 | } 5 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/node-client-configuration.yml: -------------------------------------------------------------------------------- 1 | #enabled scripts - this require groovy 2 | #script.inline: true 3 | #node.max_local_storage_nodes: 100 -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/synonyms/mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "text": { 4 | "type": "text", 5 | "analyzer": "synonym_analyzer" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mappings/test-mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "email": { 4 | "type": "text", 5 | "analyzer": "emailAnalyzer" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/get-by-id-no-hit.json: -------------------------------------------------------------------------------- 1 | { 2 | "_index" : "twitter", 3 | "_type" : "doc", 4 | "_id" : "5", 5 | "found" : false 6 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.test.context.ContextCustomizerFactory=org.springframework.data.elasticsearch.junit.jupiter.SpringDataElasticsearchExtension 2 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/settings/test-settings.yml: -------------------------------------------------------------------------------- 1 | index: 2 | number_of_shards: 1 3 | number_of_replicas: 0 4 | analysis: 5 | analyzer: 6 | emailAnalyzer: 7 | type: custom 8 | tokenizer: uax_url_email -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/config/notnested/package-info.java: -------------------------------------------------------------------------------- 1 | @org.springframework.lang.NonNullApi 2 | @org.springframework.lang.NonNullFields 3 | package org.springframework.data.elasticsearch.config.notnested; 4 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/package-info.java: -------------------------------------------------------------------------------- 1 | @org.springframework.lang.NonNullApi 2 | @org.springframework.lang.NonNullFields 3 | package org.springframework.data.elasticsearch.repositories.cdi; 4 | -------------------------------------------------------------------------------- /spring-data-opensearch-testcontainers/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ 2 | org.opensearch.spring.boot.testcontainers.service.connection.OpenSearchContainerConnectionDetailsFactory -------------------------------------------------------------------------------- /spring-data-opensearch-docker-compose/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\ 2 | org.opensearch.spring.boot.docker.compose.service.connection.OpenSearchDockerComposeConnectionDetailsFactory -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensearch-project/spring-data-opensearch/HEAD/spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * interfaces, annotations and classes related to JUnit 5 test handling. 3 | */ 4 | @org.springframework.lang.NonNullApi 5 | package org.springframework.data.elasticsearch.junit.jupiter; 6 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mappings/test-field-mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "text", 3 | "fields": { 4 | "content": { 5 | "type": "text", 6 | "term_vector":"with_positions_offsets", 7 | "store": true 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/settings/test-normalizer.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "analysis": { 4 | "normalizer": { 5 | "lower_case_normalizer": { 6 | "type": "custom", 7 | "char_filter": [], 8 | "filter": [ "lowercase" ] 9 | } 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/testcontainers-opensearch.properties: -------------------------------------------------------------------------------- 1 | # 2 | # properties defining the image, these are not passed to the container on startup 3 | # 4 | sde.testcontainers.image-name=opensearchproject/opensearch 5 | sde.testcontainers.image-version=${project.property('sde.testcontainers.image-version')} 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/resources/testcontainers-opensearch.properties: -------------------------------------------------------------------------------- 1 | # 2 | # properties defining the image, these are not passed to the container on startup 3 | # 4 | sde.testcontainers.image-name=opensearchproject/opensearch 5 | sde.testcontainers.image-version=${project.property('sde.testcontainers.image-version')} 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionSha256Sum=df67a32e86e3276d011735facb1535f64d0d88df84fa87521e90becc2d735444 7 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/core/paginating/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Test for paginating support with search_after and point_in_time API 3 | */ 4 | @org.springframework.lang.NonNullApi 5 | @org.springframework.lang.NonNullFields 6 | package org.springframework.data.elasticsearch.core.paginating; 7 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /spring-data-opensearch-docker-compose/src/test/resources/org/opensearch/spring/boot/docker/compose/service/connection/opensearch-compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | opensearch: 3 | image: opensearchproject/opensearch:3.2.0 4 | ports: 5 | - '9200' 6 | environment: 7 | - 'discovery.type=single-node' 8 | - 'DISABLE_SECURITY_PLUGIN=true' 9 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright OpenSearch Contributors. 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | 6 | opensearch: 7 | uris: https://localhost:9200 8 | username: admin 9 | password: admin 10 | 11 | spring: 12 | jackson: 13 | serialization: 14 | INDENT_OUTPUT: true 15 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mappings/test-dynamic_templates_mappings.json: -------------------------------------------------------------------------------- 1 | { 2 | "dynamic_templates": [ 3 | { 4 | "with_custom_analyzer": { 5 | "mapping": { 6 | "type": "string", 7 | "analyzer": "standard_lowercase_asciifolding" 8 | }, 9 | "path_match": "names.*" 10 | } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/update-ok-deleted.json: -------------------------------------------------------------------------------- 1 | { 2 | "_id": "1", 3 | "_index": "twitter", 4 | "_primary_term": 4, 5 | "_seq_no": 2, 6 | "_shards": { 7 | "failed": 0, 8 | "successful": 1, 9 | "total": 2 10 | }, 11 | "_type": "doc", 12 | "_version": 1, 13 | "result": "deleted" 14 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/update-ok-updated.json: -------------------------------------------------------------------------------- 1 | { 2 | "_index": "twitter", 3 | "_type": "doc", 4 | "_id": "1", 5 | "_version": 2, 6 | "result": "updated", 7 | "_shards": { 8 | "total": 2, 9 | "successful": 1, 10 | "failed": 0 11 | }, 12 | "_seq_no": 2, 13 | "_primary_term": 4 14 | } -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | This product includes software developed at 4 | The Apache Software Foundation (http://www.apache.org/). 5 | 6 | This product includes/uses Spring Data Elasticsearch (https://github.com/spring-projects/spring-data-elasticsearch), 7 | developed by the Spring team (https://github.com/spring-projects) 8 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright OpenSearch Contributors. 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | 6 | opensearch: 7 | uris: https://localhost:9200 8 | username: admin 9 | password: admin 10 | 11 | spring: 12 | jackson: 13 | serialization: 14 | INDENT_OUTPUT: true 15 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/index-ok-created.json: -------------------------------------------------------------------------------- 1 | { 2 | "_index": "twitter", 3 | "_type": "doc", 4 | "_id": "10", 5 | "_version": 1, 6 | "result": "created", 7 | "_shards": { 8 | "total": 2, 9 | "successful": 1, 10 | "failed": 0 11 | }, 12 | "_seq_no": 0, 13 | "_primary_term": 1 14 | } 15 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright OpenSearch Contributors. 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | 6 | opensearch: 7 | uris: https://localhost:9200 8 | username: admin 9 | password: admin 10 | 11 | spring: 12 | jackson: 13 | serialization: 14 | INDENT_OUTPUT: true 15 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/index-ok-updated.json: -------------------------------------------------------------------------------- 1 | { 2 | "_index" : "twitter", 3 | "_type" : "doc", 4 | "_id" : "1", 5 | "_version" : 2, 6 | "result" : "updated", 7 | "_shards" : { 8 | "total" : 2, 9 | "successful" : 1, 10 | "failed" : 0 11 | }, 12 | "_seq_no" : 1, 13 | "_primary_term" : 1 14 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/search-ok-no-hits.json: -------------------------------------------------------------------------------- 1 | { 2 | "took" : 226, 3 | "timed_out" : false, 4 | "_shards" : { 5 | "total" : 5, 6 | "successful" : 5, 7 | "skipped" : 0, 8 | "failed" : 0 9 | }, 10 | "hits" : { 11 | "total" : 0, 12 | "max_score" : null, 13 | "hits" : [ ] 14 | } 15 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/get-by-id-ok.json: -------------------------------------------------------------------------------- 1 | { 2 | "_index" : "twitter", 3 | "_type" : "doc", 4 | "_id" : "1", 5 | "_version" : 1, 6 | "found" : true, 7 | "_source" : { 8 | "user" : "kimchy", 9 | "post_date" : "2009-11-15T13:12:00", 10 | "message" : "Trying out Elasticsearch, so far so good?" 11 | } 12 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/scroll_no_more_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "_shards": { 3 | "failed": 0, 4 | "skipped": 0, 5 | "successful": 5, 6 | "total": 5 7 | }, 8 | "hits": { 9 | "hits": [], 10 | "max_score": 1.0, 11 | "total": 100 12 | }, 13 | "terminated_early": true, 14 | "timed_out": false, 15 | "took": 1 16 | } 17 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/settings/test-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "number_of_shards": "1", 4 | "number_of_replicas": "0", 5 | "analysis": { 6 | "analyzer": { 7 | "emailAnalyzer": { 8 | "type": "custom", 9 | "tokenizer": "uax_url_email" 10 | } 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.graphml 3 | .springBeans 4 | .gradle 5 | build/ 6 | 7 | atlassian-ide-plugin.xml 8 | 9 | ## Ignore svn files 10 | .svn 11 | 12 | ## ignore any target dir 13 | target 14 | 15 | ## Ignore project files created by Eclipse 16 | .settings 17 | .project 18 | .classpath 19 | 20 | ## Ignore project files created by IntelliJ IDEA 21 | *.iml 22 | *.ipr 23 | *.iws 24 | .idea 25 | /.env 26 | 27 | 28 | /zap.env 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexElasticsearchRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.elasticsearch.repositories.complex.custommethod.manualwiring; 2 | 3 | /** 4 | * @author Artur Konczak 5 | * @author Mohsin Husen 6 | */ 7 | interface ComplexElasticsearchRepositoryCustom { 8 | 9 | String doSomethingSpecial(); 10 | } 11 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.projectlombok 4 | lombok 5 | 6 | 999999 7 | 8 | 999999 9 | 10 | 20210321155422 11 | 12 | 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.warning.mode=all 2 | 3 | org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ 4 | --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ 5 | --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \ 6 | --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ 7 | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 8 | 9 | sde.testcontainers.image-version=3.3.0 10 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.projectlombok 6 | lombok 7 | 999999 8 | 9 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/bulk-ok.json: -------------------------------------------------------------------------------- 1 | { 2 | "took": 30, 3 | "errors": false, 4 | "items": [ 5 | { 6 | "update": { 7 | "_index": "twitter", 8 | "_type": "doc", 9 | "_id": "1", 10 | "_version": 2, 11 | "result": "updated", 12 | "_shards": { 13 | "total": 2, 14 | "successful": 1, 15 | "failed": 0 16 | }, 17 | "_seq_no": 2, 18 | "_primary_term": 4 19 | } 20 | } 21 | ] 22 | 23 | } -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "configMode": "AUTO", 4 | "configExternalURL": "", 5 | "projectToken": "", 6 | "baseBranches": [] 7 | }, 8 | "checkRunSettings": { 9 | "vulnerableCheckRunConclusionLevel": "failure", 10 | "displayMode": "diff", 11 | "useMendCheckNames": true 12 | }, 13 | "issueSettings": { 14 | "minSeverityLevel": "LOW", 15 | "issueType": "DEPENDENCY" 16 | }, 17 | "remediateSettings": { 18 | "workflowRules": { 19 | "enabled": true 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/aggregate-ok-no-results.json: -------------------------------------------------------------------------------- 1 | { 2 | "took" : 226, 3 | "timed_out" : false, 4 | "_shards" : { 5 | "total" : 5, 6 | "successful" : 5, 7 | "skipped" : 0, 8 | "failed" : 0 9 | }, 10 | "hits" : { 11 | "total" : 0, 12 | "max_score" : null, 13 | "hits" : [ ] 14 | }, 15 | "aggregations" : { 16 | "sterms#users" : { 17 | "doc_count_error_upper_bound" : 0, 18 | "sum_other_doc_count" : 0, 19 | "buckets" : [ ] 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-opensearch-docker-compose/src/test/resources/org/opensearch/spring/boot/docker/compose/service/connection/secure-opensearch-compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | opensearch: 3 | image: opensearchproject/opensearch:3.2.0 4 | ports: 5 | - '9200' 6 | healthcheck: 7 | test: ["CMD-SHELL", "curl -k -u admin:D3v3l0p-ment --silent --fail https://localhost:9200/ || exit 1"] 8 | interval: 10s 9 | timeout: 10s 10 | retries: 3 11 | environment: 12 | - 'discovery.type=single-node' 13 | - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=D3v3l0p-ment' 14 | -------------------------------------------------------------------------------- /.github/workflows/add-untriaged.yml: -------------------------------------------------------------------------------- 1 | name: Apply 'untriaged' label during issue lifecycle 2 | 3 | on: 4 | issues: 5 | types: [opened, reopened, transferred] 6 | 7 | jobs: 8 | apply-label: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/github-script@v6 12 | with: 13 | script: | 14 | github.rest.issues.addLabels({ 15 | issue_number: context.issue.number, 16 | owner: context.repo.owner, 17 | repo: context.repo.repo, 18 | labels: ['untriaged'] 19 | }) 20 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/ScriptField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.orhlc; 11 | 12 | import org.opensearch.script.Script; 13 | 14 | /** 15 | * Scripted field 16 | * 17 | * @since 0.1 18 | */ 19 | public record ScriptField(String fieldName, Script script) { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/synonyms/settings-with-external-file.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "number_of_shards": "1", 4 | "number_of_replicas": "0", 5 | "analysis": { 6 | "analyzer": { 7 | "synonym_analyzer": { 8 | "tokenizer": "whitespace", 9 | "filter": [ 10 | "synonym_filter" 11 | ] 12 | } 13 | }, 14 | "filter": { 15 | "synonym_filter": { 16 | "type": "synonym", 17 | "synonyms_path": "synonyms.txt", 18 | "ignore_case": "true" 19 | } 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /spring-data-opensearch-testcontainers/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{HH:mm:ss.SSS} %-5level %logger - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.opensearch.spring.boot.autoconfigure.OpenSearchClientAutoConfiguration 2 | org.opensearch.spring.boot.autoconfigure.OpenSearchRestClientAutoConfiguration 3 | org.opensearch.spring.boot.autoconfigure.OpenSearchRestHighLevelClientAutoConfiguration 4 | org.opensearch.spring.boot.autoconfigure.ReactiveOpenSearchClientAutoConfiguration 5 | org.opensearch.spring.boot.autoconfigure.data.OpenSearchDataAutoConfiguration 6 | org.opensearch.spring.boot.autoconfigure.data.ReactiveOpenSearchRepositoriesAutoConfiguration 7 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/update-error-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "error": { 3 | "index": "twitter", 4 | "index_uuid": "C91lAFXcRR6GTpYv6QIJFQ", 5 | "reason": "[doc][101]: document missing", 6 | "root_cause": [ 7 | { 8 | "index": "twitter", 9 | "index_uuid": "C91lAFXcRR6GTpYv6QIJFQ", 10 | "reason": "[doc][101]: document missing", 11 | "shard": "1", 12 | "type": "document_missing_exception" 13 | } 14 | ], 15 | "shard": "1", 16 | "type": "document_missing_exception" 17 | }, 18 | "status": 404 19 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/mappings/test-dynamic_templates_mappings_two.json: -------------------------------------------------------------------------------- 1 | { 2 | "dynamic_templates": [ 3 | { 4 | "with_custom_analyzer": { 5 | "mapping": { 6 | "type": "string", 7 | "analyzer": "standard_lowercase_asciifolding" 8 | }, 9 | "path_match": "names.*" 10 | } 11 | }, 12 | { 13 | "participantA1_with_custom_analyzer": { 14 | "mapping": { 15 | "type": "string", 16 | "analyzer": "standard_lowercase_asciifolding" 17 | }, 18 | "path_match": "participantA1.*" 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster_name": "elasticsearch", 3 | "cluster_uuid": "r1tpSEemQZiSVJbfAqOLjg", 4 | "name": "T14BIoj", 5 | "tagline": "You Know, for Search", 6 | "version": { 7 | "build_date": "2018-08-17T23:18:47.308994Z", 8 | "build_flavor": "default", 9 | "build_hash": "595516e", 10 | "build_snapshot": false, 11 | "build_type": "tar", 12 | "lucene_version": "7.4.0", 13 | "minimum_index_compatibility_version": "5.0.0", 14 | "minimum_wire_compatibility_version": "5.6.0", 15 | "number": "6.4.0" 16 | } 17 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/index-template-requests/put-index-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "index_patterns": [ 3 | "test-*" 4 | ], 5 | "settings": { 6 | "index": { 7 | "number_of_replicas": "2", 8 | "number_of_shards": "3", 9 | "refresh_interval": "7s", 10 | "store": { 11 | "type": "oops" 12 | } 13 | } 14 | }, 15 | "mappings": { 16 | "properties": { 17 | "price": { 18 | "type": "double" 19 | } 20 | } 21 | }, 22 | "aliases": { 23 | "alias1": {}, 24 | "alias2": {}, 25 | "alias3": { 26 | "routing": "11" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-opensearch-test-autoconfigure/src/main/resources/META-INF/spring/org.opensearch.spring.boot.autoconfigure.test.AutoConfigureDataOpenSearch.imports: -------------------------------------------------------------------------------- 1 | org.opensearch.spring.boot.autoconfigure.OpenSearchClientAutoConfiguration 2 | org.opensearch.spring.boot.autoconfigure.OpenSearchRestClientAutoConfiguration 3 | org.opensearch.spring.boot.autoconfigure.OpenSearchRestHighLevelClientAutoConfiguration 4 | org.opensearch.spring.boot.autoconfigure.ReactiveOpenSearchClientAutoConfiguration 5 | org.opensearch.spring.boot.autoconfigure.data.OpenSearchDataAutoConfiguration 6 | org.opensearch.spring.boot.autoconfigure.data.ReactiveOpenSearchRepositoriesAutoConfiguration 7 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/OpenSearchConnectionDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure; 7 | 8 | import java.util.List; 9 | import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails; 10 | 11 | public interface OpenSearchConnectionDetails extends ConnectionDetails { 12 | 13 | List getUris(); 14 | 15 | String getUsername(); 16 | 17 | String getPassword(); 18 | 19 | default String getPathPrefix() { 20 | return null; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/synonyms/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": { 3 | "number_of_shards": "1", 4 | "number_of_replicas": "0", 5 | "analysis": { 6 | "analyzer": { 7 | "synonym_analyzer": { 8 | "type": "custom", 9 | "tokenizer": "whitespace", 10 | "filter": [ 11 | "synonym_filter" 12 | ] 13 | } 14 | }, 15 | "filter": { 16 | "synonym_filter": { 17 | "type": "synonym", 18 | "lenient": true, 19 | "synonyms": [ 20 | "british,english", 21 | "queen,monarch" 22 | ] 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/search-ok-single-hit.json: -------------------------------------------------------------------------------- 1 | { 2 | "took" : 52, 3 | "timed_out" : false, 4 | "_shards" : { 5 | "total" : 5, 6 | "successful" : 5, 7 | "skipped" : 0, 8 | "failed" : 0 9 | }, 10 | "hits" : { 11 | "total" : 1, 12 | "max_score" : 0.2876821, 13 | "hits" : [ 14 | { 15 | "_index" : "twitter", 16 | "_type" : "doc", 17 | "_id" : "2", 18 | "_score" : 0.2876821, 19 | "_source" : { 20 | "user" : "kimchy", 21 | "post_date" : "2009-11-15T14:12:12", 22 | "message" : "Another tweet, will it be indexed?" 23 | } 24 | } 25 | ] 26 | } 27 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/aggregate-ok-single-result.json: -------------------------------------------------------------------------------- 1 | { 2 | "took": 52, 3 | "timed_out": false, 4 | "_shards": { 5 | "total": 5, 6 | "successful": 5, 7 | "skipped": 0, 8 | "failed": 0 9 | }, 10 | "hits": { 11 | "total": 0, 12 | "max_score": null, 13 | "hits": [ ] 14 | }, 15 | "aggregations": { 16 | "sterms#users": { 17 | "doc_count_error_upper_bound": 0, 18 | "sum_other_doc_count": 0, 19 | "buckets": [ 20 | { 21 | "key": "kimchy", 22 | "doc_count": 2 23 | }, 24 | { 25 | "key": "elastic", 26 | "doc_count": 1 27 | } 28 | ] 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | [Describe what this change achieves] 3 | 4 | ### Issues Resolved 5 | [List any issues this PR will resolve] 6 | 7 | ### Check List 8 | - [ ] New functionality includes testing. 9 | - [ ] All tests pass 10 | - [ ] New functionality has been documented. 11 | - [ ] New functionality has javadoc added 12 | - [ ] Commits are signed per the DCO using --signoff 13 | 14 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 15 | For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). 16 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/main/java/org/opensearch/data/example/MarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfiguration; 11 | 12 | @SpringBootApplication(exclude = DataElasticsearchAutoConfiguration.class) 13 | public class MarketplaceApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(MarketplaceConfiguration.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/main/java/org/opensearch/data/example/MarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfiguration; 11 | 12 | @SpringBootApplication(exclude = DataElasticsearchAutoConfiguration.class) 13 | public class MarketplaceApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(MarketplaceConfiguration.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/main/java/org/opensearch/data/example/MarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example; 7 | 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfiguration; 11 | 12 | @SpringBootApplication(exclude = DataElasticsearchAutoConfiguration.class) 13 | public class MarketplaceApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(MarketplaceConfiguration.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-opensearch-test-autoconfigure/src/main/java/org/opensearch/spring/boot/autoconfigure/test/OpenSearchTypeExcludeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.test; 7 | 8 | import org.springframework.boot.context.TypeExcludeFilter; 9 | import org.springframework.boot.test.context.filter.annotation.StandardAnnotationCustomizableTypeExcludeFilter; 10 | 11 | /** 12 | * {@link TypeExcludeFilter} for {@link DataElasticsearchTest}. 13 | */ 14 | class OpenSearchTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeFilter { 15 | OpenSearchTypeExcludeFilter(Class testClass) { 16 | super(testClass); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/multi-get-ok-2-hits.json: -------------------------------------------------------------------------------- 1 | { 2 | "docs": [ 3 | { 4 | "_index": "twitter", 5 | "_type": "doc", 6 | "_id": "1", 7 | "_version": 1, 8 | "found": true, 9 | "_source": { 10 | "user": "kimchy", 11 | "post_date": "2009-11-15T13:12:00", 12 | "message": "Trying out Elasticsearch, so far so good?" 13 | } 14 | }, 15 | { 16 | "_index": "twitter", 17 | "_type": "doc", 18 | "_id": "2", 19 | "_version": 1, 20 | "found": true, 21 | "_source": { 22 | "user": "kimchy", 23 | "post_date": "2009-11-15T14:12:12", 24 | "message": "Another tweet, will it be indexed?" 25 | } 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/SearchHitsUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.orhlc; 11 | 12 | import org.opensearch.search.SearchHits; 13 | 14 | /** 15 | * Utility class to prevent leaking of Lucene API into Spring Data OpenSearch. 16 | * @since 0.1 17 | */ 18 | public final class SearchHitsUtil { 19 | private SearchHitsUtil() {} 20 | 21 | public static long getTotalCount(SearchHits searchHits) { 22 | return searchHits.getTotalHits().value(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/java/org/opensearch/spring/boot/autoconfigure/data/entity/ProductOpenSearchRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data.entity; 7 | 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.Pageable; 10 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 11 | 12 | public interface ProductOpenSearchRepository extends ElasticsearchRepository { 13 | Page findAll(Pageable pageable); 14 | 15 | Page findByNameLikeAllIgnoringCase(String name, Pageable pageable); 16 | 17 | Product findByNameAllIgnoringCase(String name, String country); 18 | } 19 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/java/org/opensearch/spring/boot/autoconfigure/data/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data.repository; 7 | 8 | import org.opensearch.spring.boot.autoconfigure.data.entity.Product; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.data.repository.Repository; 12 | 13 | public interface ProductRepository extends Repository { 14 | Page findAll(Pageable pageable); 15 | 16 | Page findByNameLikeAllIgnoringCase(String name, Pageable pageable); 17 | 18 | Product findByNameAllIgnoringCase(String name, String country); 19 | } 20 | -------------------------------------------------------------------------------- /jenkins/release.jenkinsFile: -------------------------------------------------------------------------------- 1 | lib = library(identifier: 'jenkins@10.2.2', retriever: modernSCM([ 2 | $class: 'GitSCMSource', 3 | remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git', 4 | ])) 5 | 6 | standardReleasePipelineWithGenericTrigger( 7 | overrideDockerImage: 'opensearchstaging/ci-runner:release-centos7-clients-v4', 8 | tokenIdCredential: 'jenkins-spring-data-opensearch-generic-webhook-token', 9 | causeString: 'A tag was cut on opensearch-project/spring-data-opensearch repository causing this workflow to run', 10 | downloadReleaseAsset: true, 11 | publishRelease: true) { 12 | publishToMaven( 13 | signingArtifactsPath: "$WORKSPACE/repository/", 14 | mavenArtifactsPath: "$WORKSPACE/repository/", 15 | autoPublish: true 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/index/IndexTemplateOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.index; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.data.elasticsearch.core.index.IndexTemplateIntegrationTests; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | @ContextConfiguration(classes = {OpenSearchTemplateConfiguration.class}) 17 | public class IndexTemplateOSCIntegrationTests extends IndexTemplateIntegrationTests {} 18 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/highlights/highlights-with-parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "boundary_chars": "#+*", 3 | "boundary_max_scan": 7, 4 | "boundary_scanner": "CHARS", 5 | "boundary_scanner_locale": "de-DE", 6 | "encoder": "html", 7 | "force_source": true, 8 | "fragmenter": "span", 9 | "fragment_size": 5, 10 | "no_match_size": 2, 11 | "number_of_fragments": 3, 12 | "order": "score", 13 | "phrase_limit": 42, 14 | "pre_tags": [ 15 | "", 16 | "" 17 | ], 18 | "post_tags": [ 19 | "", 20 | "" 21 | ], 22 | "require_field_match": false, 23 | "type": "plain", 24 | "fields": { 25 | "some-field": { 26 | "fragment_offset": 3, 27 | "number_of_fragments": 4, 28 | "matched_fields": [ 29 | "some-field", 30 | "other-field" 31 | ] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/java/org/opensearch/spring/boot/autoconfigure/data/entity/ReactiveProductOpenSearchRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data.entity; 7 | 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; 10 | import reactor.core.publisher.Flux; 11 | import reactor.core.publisher.Mono; 12 | 13 | public interface ReactiveProductOpenSearchRepository extends ReactiveElasticsearchRepository { 14 | Flux findAll(Sort sort); 15 | 16 | Flux findByNameLikeAllIgnoringCase(String name, Sort sort); 17 | 18 | Mono findByNameAllIgnoringCase(String name, String country); 19 | } 20 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/index/IndexTemplateORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.index; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.data.elasticsearch.core.index.IndexTemplateIntegrationTests; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | @ContextConfiguration(classes = {OpenSearchRestTemplateConfiguration.class}) 17 | public class IndexTemplateORHLCIntegrationTests extends IndexTemplateIntegrationTests {} 18 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/cluster/ClusterOperationsOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.cluster; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.data.elasticsearch.core.cluster.ClusterOperationsIntegrationTests; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | @ContextConfiguration(classes = {OpenSearchTemplateConfiguration.class}) 17 | public class ClusterOperationsOSCIntegrationTests extends ClusterOperationsIntegrationTests {} 18 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/aggregate-ok-multiple-results.json: -------------------------------------------------------------------------------- 1 | { 2 | "took": 52, 3 | "timed_out": false, 4 | "_shards": { 5 | "total": 5, 6 | "successful": 5, 7 | "skipped": 0, 8 | "failed": 0 9 | }, 10 | "hits": { 11 | "total": 0, 12 | "max_score": null, 13 | "hits": [ ] 14 | }, 15 | "aggregations": { 16 | "sterms#users": { 17 | "doc_count_error_upper_bound": 0, 18 | "sum_other_doc_count": 0, 19 | "buckets": [ 20 | { 21 | "key": "kimchy", 22 | "doc_count": 2 23 | }, 24 | { 25 | "key": "elastic", 26 | "doc_count": 1 27 | } 28 | ] 29 | }, 30 | "max#max_post_date": { 31 | "value" : 1.263519998E12, 32 | "value_as_string" : "2010-01-15T01:46:38.000Z" 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/cluster/ClusterOperationsORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.cluster; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.data.elasticsearch.core.cluster.ClusterOperationsIntegrationTests; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | @ContextConfiguration(classes = {OpenSearchRestTemplateConfiguration.class}) 17 | public class ClusterOperationsORHLCIntegrationTests extends ClusterOperationsIntegrationTests {} 18 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexElasticsearchRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.elasticsearch.repositories.complex.custommethod.autowiring; 2 | 3 | import static org.assertj.core.api.AssertionsForClassTypes.*; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.data.elasticsearch.core.ElasticsearchOperations; 7 | 8 | /** 9 | * @author Artur Konczak 10 | * @author Peter-Josef Meisch 11 | */ 12 | public class ComplexElasticsearchRepositoryImpl implements ComplexElasticsearchRepositoryCustom { 13 | 14 | @Autowired private ElasticsearchOperations operations; 15 | 16 | @Override 17 | public String doSomethingSpecial() { 18 | 19 | assertThat(operations.getElasticsearchConverter()).isNotNull(); 20 | 21 | return "2+2=4"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/main/java/org/opensearch/data/example/repository/MarketplaceRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | import org.opensearch.data.example.model.Product; 11 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 12 | import org.springframework.stereotype.Repository; 13 | 14 | /** 15 | * See please https://github.com/spring-projects/spring-data-elasticsearch/blob/main/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc 16 | */ 17 | @Repository 18 | public interface MarketplaceRepository extends ElasticsearchRepository { 19 | List findByNameLikeAndPriceGreaterThan(String name, BigDecimal price); 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/main/java/org/opensearch/data/example/repository/MarketplaceRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | import org.opensearch.data.example.model.Product; 11 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 12 | import org.springframework.stereotype.Repository; 13 | 14 | /** 15 | * See please https://github.com/spring-projects/spring-data-elasticsearch/blob/main/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc 16 | */ 17 | @Repository 18 | public interface MarketplaceRepository extends ElasticsearchRepository { 19 | List findByNameLikeAndPriceGreaterThan(String name, BigDecimal price); 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/multi-get-ok-2-hits-1-unavailable.json: -------------------------------------------------------------------------------- 1 | { 2 | "docs": [ 3 | { 4 | "_index": "twitter", 5 | "_type": "doc", 6 | "_id": "1", 7 | "_version": 1, 8 | "found": true, 9 | "_source": { 10 | "user": "kimchy", 11 | "post_date": "2009-11-15T13:12:00", 12 | "message": "Trying out Elasticsearch, so far so good?" 13 | } 14 | }, 15 | { 16 | "_index": "twitter", 17 | "_type": "_doc", 18 | "_id": "2", 19 | "found": false 20 | }, 21 | { 22 | "_index": "twitter", 23 | "_type": "doc", 24 | "_id": "3", 25 | "_version": 1, 26 | "found": true, 27 | "_source": { 28 | "user": "elastic", 29 | "post_date": "2010-01-15T01:46:38", 30 | "message": "Building the site, should be kewl" 31 | } 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/java/org/opensearch/spring/boot/autoconfigure/data/repository/ReactiveProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data.repository; 7 | 8 | import org.opensearch.spring.boot.autoconfigure.data.entity.Product; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.data.repository.reactive.ReactiveSortingRepository; 12 | import reactor.core.publisher.Mono; 13 | 14 | public interface ReactiveProductRepository extends ReactiveSortingRepository { 15 | Mono> findAll(Pageable pageable); 16 | 17 | Mono> findByNameLikeAllIgnoringCase(String name, Pageable pageable); 18 | 19 | Mono findByNameAllIgnoringCase(String name, String country); 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch-test-autoconfigure/src/main/java/org/opensearch/spring/boot/autoconfigure/test/DataOpenSearchTestContextBootstrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.test; 7 | 8 | import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; 9 | import org.springframework.core.annotation.MergedAnnotations; 10 | import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; 11 | 12 | class DataOpenSearchTestContextBootstrapper extends SpringBootTestContextBootstrapper { 13 | @Override 14 | protected String[] getProperties(Class testClass) { 15 | return MergedAnnotations.from(testClass, SearchStrategy.INHERITED_ANNOTATIONS) 16 | .get(DataOpenSearchTest.class) 17 | .getValue("properties", String[].class) 18 | .orElse(null); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/main/java/org/opensearch/data/example/repository/ReactiveMarketplaceRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import java.math.BigDecimal; 9 | import org.opensearch.data.example.model.Product; 10 | import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; 11 | import org.springframework.stereotype.Repository; 12 | import reactor.core.publisher.Flux; 13 | 14 | /** 15 | * See please https://github.com/spring-projects/spring-data-elasticsearch/blob/main/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc 16 | */ 17 | @Repository 18 | public interface ReactiveMarketplaceRepository extends ReactiveElasticsearchRepository { 19 | Flux findByNameLikeAndPriceGreaterThan(String name, BigDecimal price); 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/Tags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.junit.jupiter; 17 | 18 | /** 19 | * @author Peter-Josef Meisch 20 | */ 21 | public interface Tags { 22 | String INTEGRATION_TEST = "integration-test"; 23 | } 24 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/core/OpenSearchOperations.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.data.core; 2 | 3 | import java.time.Duration; 4 | import java.util.List; 5 | import org.springframework.data.elasticsearch.core.ElasticsearchOperations; 6 | 7 | /** 8 | * The extension over {@link ElasticsearchOperations} with OpenSearch specific operations. 9 | */ 10 | public interface OpenSearchOperations extends ElasticsearchOperations { 11 | /** 12 | * Return all active point in time searches 13 | * @return all active point in time searches 14 | */ 15 | List listPointInTime(); 16 | 17 | /** 18 | * Describes the point in time entry 19 | * 20 | * @param id the point in time id 21 | * @param creationTime the time this point in time was created 22 | * @param keepAlive the new keep alive value for this point in time 23 | */ 24 | record PitInfo(String id, long creationTime, Duration keepAlive) { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/test/java/org/opensearch/spring/boot/autoconfigure/data/entity/Product.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data.entity; 7 | 8 | import org.springframework.data.annotation.Id; 9 | import org.springframework.data.elasticsearch.annotations.Document; 10 | import org.springframework.data.elasticsearch.annotations.Setting; 11 | import org.springframework.lang.Nullable; 12 | 13 | @Document(indexName = "products") 14 | @Setting(shards = 1, replicas = 0, refreshInterval = "-1") 15 | public class Product { 16 | @Nullable 17 | @Id 18 | private String name; 19 | 20 | public Product(@Nullable String name) { 21 | this.name = name; 22 | } 23 | 24 | @Nullable 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(@Nullable String name) { 30 | this.name = name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/config/AuditingOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.config; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Import; 14 | import org.springframework.data.elasticsearch.config.AuditingIntegrationTests; 15 | import org.springframework.test.context.ContextConfiguration; 16 | 17 | @ContextConfiguration(classes = {AuditingOSCIntegrationTests.Config.class}) 18 | public class AuditingOSCIntegrationTests extends AuditingIntegrationTests { 19 | 20 | @Import({OpenSearchTemplateConfiguration.class, AuditingIntegrationTests.Config.class}) 21 | static class Config {} 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/config/AuditingORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.config; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Import; 14 | import org.springframework.data.elasticsearch.config.AuditingIntegrationTests; 15 | import org.springframework.test.context.ContextConfiguration; 16 | 17 | @ContextConfiguration(classes = {AuditingORHLCIntegrationTests.Config.class}) 18 | public class AuditingORHLCIntegrationTests extends AuditingIntegrationTests { 19 | 20 | @Import({OpenSearchRestTemplateConfiguration.class, AuditingIntegrationTests.Config.class}) 21 | static class Config {} 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package contains classes that use the new OpenSearch client library (org.opensearch.client:opensearch-java) 19 | * to access OpenSearch. 20 | */ 21 | @org.springframework.lang.NonNullApi 22 | @org.springframework.lang.NonNullFields 23 | package org.opensearch.data.client.osc; 24 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/scroll_ok.json: -------------------------------------------------------------------------------- 1 | { 2 | "_shards": { 3 | "failed": 0, 4 | "skipped": 0, 5 | "successful": 5, 6 | "total": 5 7 | }, 8 | "hits": { 9 | "hits": [ 10 | { 11 | "_index": "twitter", 12 | "_type": "doc", 13 | "_id": "2", 14 | "_score": 0.2876821, 15 | "_source": { 16 | "user": "kimchy", 17 | "post_date": "2009-11-15T14:12:12", 18 | "message": "Another tweet, will it be indexed?" 19 | } 20 | }, 21 | { 22 | "_index": "twitter", 23 | "_type": "doc", 24 | "_id": "1", 25 | "_score": 0.2876821, 26 | "_source": { 27 | "user": "kimchy", 28 | "post_date": "2009-11-15T13:12:00", 29 | "message": "Trying out Elasticsearch, so far so good?" 30 | } 31 | } 32 | ], 33 | "max_score": 1.0, 34 | "total": 100 35 | }, 36 | "terminated_early": true, 37 | "timed_out": false, 38 | "took": 1 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-opensearch-docker-compose/src/main/java/org/opensearch/spring/boot/docker/compose/service/connection/OpenSearchEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.docker.compose.service.connection; 7 | 8 | import java.util.Map; 9 | 10 | class OpenSearchEnvironment { 11 | 12 | private final String username = "admin"; 13 | 14 | private final boolean securityEnabled; 15 | 16 | private final String password; 17 | 18 | OpenSearchEnvironment(Map env) { 19 | this.securityEnabled = !Boolean.parseBoolean(env.get("DISABLE_SECURITY_PLUGIN")); 20 | this.password = env.getOrDefault("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "admin"); 21 | } 22 | 23 | public String getUsername() { 24 | return this.username; 25 | } 26 | 27 | public boolean isSecurityEnabled() { 28 | return this.securityEnabled; 29 | } 30 | 31 | public String getPassword() { 32 | return this.password; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/SamplePersonRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.elasticsearch.repositories.cdi; 18 | 19 | /** 20 | * @author Mark Paluch 21 | * @see DATAES-113 22 | */ 23 | interface SamplePersonRepositoryCustom { 24 | 25 | int returnOne(); 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/QueryParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.custommethod; 17 | 18 | /** 19 | * Used as a parameter referenced by SpEL in query method tests. 20 | * 21 | * @param value content 22 | * @author Haibo Liu 23 | */ 24 | public record QueryParameter(String value) { 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/search-ok-multiple-hits.json: -------------------------------------------------------------------------------- 1 | { 2 | "took" : 52, 3 | "timed_out" : false, 4 | "_shards" : { 5 | "total" : 5, 6 | "successful" : 5, 7 | "skipped" : 0, 8 | "failed" : 0 9 | }, 10 | "hits" : { 11 | "total" : 2, 12 | "max_score" : 0.2876821, 13 | "hits" : [ 14 | { 15 | "_index" : "twitter", 16 | "_type" : "doc", 17 | "_id" : "2", 18 | "_score" : 0.2876821, 19 | "_source" : { 20 | "user" : "kimchy", 21 | "post_date" : "2009-11-15T14:12:12", 22 | "message" : "Another tweet, will it be indexed?" 23 | } 24 | }, 25 | { 26 | "_index" : "twitter", 27 | "_type" : "doc", 28 | "_id" : "1", 29 | "_score" : 0.2876821, 30 | "_source" : { 31 | "user" : "kimchy", 32 | "post_date" : "2009-11-15T13:12:00", 33 | "message" : "Trying out Elasticsearch, so far so good?" 34 | } 35 | } 36 | ] 37 | } 38 | } -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/geohash/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * package collecting classes needed for GeoHash calculations. Copied from Elasticsearch 7.10 code which was the last 19 | * one under the Apache license V2. 20 | * 21 | * @author Peter-Josef Meisch 22 | * @since 4.4 23 | */ 24 | package org.springframework.data.elasticsearch.utils.geohash; 25 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/IndexBuilder.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.elasticsearch.utils; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | import org.springframework.core.annotation.AnnotationUtils; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.elasticsearch.core.query.IndexQuery; 8 | 9 | /** 10 | * Created by akonczak on 02/12/2015. 11 | * 12 | * @author Peter-Josef Meisch 13 | */ 14 | public class IndexBuilder { 15 | 16 | public static IndexQuery buildIndex(Object object) { 17 | for (Field f : object.getClass().getDeclaredFields()) { 18 | 19 | if (AnnotationUtils.findAnnotation(f, Id.class) != null) { 20 | try { 21 | f.setAccessible(true); 22 | IndexQuery indexQuery = new IndexQuery(); 23 | indexQuery.setId((String) f.get(object)); 24 | indexQuery.setObject(object); 25 | return indexQuery; 26 | } catch (IllegalAccessException e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | } 31 | throw new RuntimeException("Missing @Id field"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexElasticsearchRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.complex.custommethod.autowiring; 17 | 18 | /** 19 | * @author Artur Konczak 20 | * @author Mohsin Husen 21 | */ 22 | public interface ComplexElasticsearchRepositoryCustom { 23 | 24 | String doSomethingSpecial(); 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/OpenSearchAggregations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.orhlc; 11 | 12 | import org.opensearch.search.aggregations.Aggregations; 13 | import org.springframework.data.elasticsearch.core.AggregationsContainer; 14 | import org.springframework.lang.NonNull; 15 | 16 | /** 17 | * AggregationsContainer implementation for the OpenSearch aggregations. 18 | * @since 0.1 19 | */ 20 | public class OpenSearchAggregations implements AggregationsContainer { 21 | 22 | private final Aggregations aggregations; 23 | 24 | public OpenSearchAggregations(Aggregations aggregations) { 25 | this.aggregations = aggregations; 26 | } 27 | 28 | @NonNull 29 | @Override 30 | public Aggregations aggregations() { 31 | return aggregations; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/OpenSearchClusterOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.orhlc; 11 | 12 | import org.springframework.data.elasticsearch.core.cluster.ClusterOperations; 13 | import org.springframework.util.Assert; 14 | 15 | /** 16 | * OpenSearch cluster operations 17 | * @since 0.1 18 | */ 19 | public class OpenSearchClusterOperations { 20 | /** 21 | * Creates a ClusterOperations for a {@link OpenSearchRestTemplate}. 22 | * 23 | * @param template the template, must not be {@literal null} 24 | * @return ClusterOperations 25 | */ 26 | public static ClusterOperations forTemplate(OpenSearchRestTemplate template) { 27 | 28 | Assert.notNull(template, "template must not be null"); 29 | 30 | return new DefaultClusterOperations(template); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/CriteriaQueryException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.opensearch.data.client.osc; 17 | 18 | import org.springframework.dao.UncategorizedDataAccessException; 19 | 20 | /** 21 | * @author Peter-Josef Meisch 22 | * @since 4.4 23 | */ 24 | public class CriteriaQueryException extends UncategorizedDataAccessException { 25 | public CriteriaQueryException(String msg) { 26 | super(msg, null); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/SamplePersonRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.elasticsearch.repositories.cdi; 18 | 19 | /** 20 | * @author Mark Paluch 21 | * @see DATAES-113 22 | */ 23 | class SamplePersonRepositoryImpl implements SamplePersonRepositoryCustom { 24 | 25 | @Override 26 | public int returnOne() { 27 | return 1; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | This document contains a list of maintainers in this repo. See [opensearch-project/.github/RESPONSIBILITIES.md](https://github.com/opensearch-project/.github/blob/main/RESPONSIBILITIES.md#maintainer-responsibilities) that explains what the role of maintainer means, what maintainers do in this and other repos, and how they should be doing it. If you're interested in contributing, and becoming a maintainer, see [CONTRIBUTING](CONTRIBUTING.md). 4 | 5 | ## Current Maintainers 6 | 7 | | Maintainer | GitHub ID | Affiliation | 8 | | ------------- | ----------------------------------------- | ----------- | 9 | | Andriy Redko | [reta](https://github.com/reta) | Independent | 10 | | David Venable | [dlvenable](https://github.com/dlvenable) | Amazon | 11 | | Andrew Ross | [andrross](https://github.com/andrross) | Amazon | 12 | 13 | ## Emeritus 14 | 15 | | Maintainer | GitHub ID | Affiliation | 16 | | ------------------ | ----------------------------------- | ----------- | 17 | | Daniel Doubrovkine | [dblock](https://github.com/dblock) | Independent | 18 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/test/java/org/opensearch/data/example/repository/TestMarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.data.example.repository; 2 | 3 | import org.opensearch.data.example.MarketplaceApplication; 4 | import org.opensearch.testcontainers.OpenSearchContainer; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.test.context.TestConfiguration; 7 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | public class TestMarketplaceApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.from(MarketplaceApplication::main) 14 | .with(ContainerConfig.class) 15 | .run(args); 16 | } 17 | 18 | @TestConfiguration(proxyBeanMethods = false) 19 | static class ContainerConfig { 20 | 21 | @Bean 22 | @ServiceConnection 23 | OpenSearchContainer opensearchContainer() { 24 | return new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0"); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/ClusterConnectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.junit.jupiter; 17 | 18 | /** 19 | * @author Peter-Josef Meisch 20 | */ 21 | public class ClusterConnectionException extends RuntimeException { 22 | public ClusterConnectionException(String message) { 23 | super(message); 24 | } 25 | 26 | public ClusterConnectionException(Throwable cause) { 27 | super(cause); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/test/java/org/opensearch/data/example/repository/TestMarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.data.example.repository; 2 | 3 | import org.opensearch.data.example.MarketplaceApplication; 4 | import org.opensearch.testcontainers.OpenSearchContainer; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.test.context.TestConfiguration; 7 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | public class TestMarketplaceApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.from(MarketplaceApplication::main) 14 | .with(ContainerConfig.class) 15 | .run(args); 16 | } 17 | 18 | @TestConfiguration(proxyBeanMethods = false) 19 | static class ContainerConfig { 20 | 21 | @Bean 22 | @ServiceConnection 23 | OpenSearchContainer opensearchContainer() { 24 | return new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0"); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/test/java/org/opensearch/data/example/repository/TestMarketplaceApplication.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.data.example.repository; 2 | 3 | import org.opensearch.data.example.MarketplaceApplication; 4 | import org.opensearch.testcontainers.OpenSearchContainer; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.test.context.TestConfiguration; 7 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 8 | import org.springframework.context.annotation.Bean; 9 | 10 | public class TestMarketplaceApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.from(MarketplaceApplication::main) 14 | .with(ContainerConfig.class) 15 | .run(args); 16 | } 17 | 18 | @TestConfiguration(proxyBeanMethods = false) 19 | static class ContainerConfig { 20 | 21 | @Bean 22 | @ServiceConnection 23 | OpenSearchContainer opensearchContainer() { 24 | return new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0"); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/OpenSearchAggregation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.opensearch.data.client.osc; 17 | 18 | import org.springframework.data.elasticsearch.core.AggregationContainer; 19 | 20 | /** 21 | * {@link AggregationContainer} for a {@link Aggregation} that holds OpenSearch data. 22 | * 23 | * @author Peter-Josef Meisch 24 | * @since 4.4 25 | */ 26 | public record OpenSearchAggregation(Aggregation aggregation) implements AggregationContainer { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/SamplePersonRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.cdi; 17 | 18 | import org.springframework.data.repository.Repository; 19 | 20 | /** 21 | * @author Mark Paluch 22 | * @see DATAES-113 23 | */ 24 | public interface SamplePersonRepository 25 | extends Repository, SamplePersonRepositoryCustom { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-opensearch-test-autoconfigure/src/main/java/org/opensearch/spring/boot/autoconfigure/test/AutoConfigureDataOpenSearch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.test; 7 | 8 | import java.lang.annotation.Documented; 9 | import java.lang.annotation.ElementType; 10 | import java.lang.annotation.Inherited; 11 | import java.lang.annotation.Retention; 12 | import java.lang.annotation.RetentionPolicy; 13 | import java.lang.annotation.Target; 14 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; 15 | import org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfiguration; 16 | 17 | /** 18 | * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data OpenSearch tests. 19 | * Most tests should consider using {@link DataOpenSearchTest} rather than using this annotation 20 | * directly. 21 | */ 22 | @Target(ElementType.TYPE) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Documented 25 | @Inherited 26 | @ImportAutoConfiguration(exclude = DataElasticsearchAutoConfiguration.class) 27 | public @interface AutoConfigureDataOpenSearch {} 28 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/QualifiedProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.cdi; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * @author Mark Paluch 22 | * @see DATAES-234 23 | */ 24 | @PersonDB 25 | @OtherQualifier 26 | public interface QualifiedProductRepository extends CrudRepository { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/EntityAsMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.opensearch.data.client.osc; 17 | 18 | import org.springframework.data.elasticsearch.support.DefaultStringObjectMap; 19 | 20 | /** 21 | * A Map<String,Object> to represent any entity as it's returned from OpenSearch and before it is converted to a 22 | * {@link org.springframework.data.elasticsearch.core.document.Document}. 23 | * 24 | * @author Peter-Josef Meisch 25 | * @since 4.4 26 | */ 27 | public class EntityAsMap extends DefaultStringObjectMap {} 28 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/EnabledIfOpenSearchVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client; 11 | 12 | import java.lang.annotation.ElementType; 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.RetentionPolicy; 15 | import java.lang.annotation.Target; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | /** 19 | * Meta-annotation to enable OpenSearch-specific test cases only on or after specific version 20 | */ 21 | @Target({ElementType.TYPE, ElementType.METHOD}) 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @ExtendWith(EnabledIfOpenSearchVersionCondition.class) 24 | public @interface EnabledIfOpenSearchVersion { 25 | /** 26 | * The minimal required version of the OpenSearch this test could run on 27 | */ 28 | String onOrAfter(); 29 | 30 | /** 31 | * The reason (issue reference) why this test is not runnable on previous version 32 | */ 33 | String reason(); 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/OpenSearchRestHighLevelClientAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure; 7 | 8 | import org.opensearch.client.RestHighLevelClient; 9 | import org.opensearch.spring.boot.autoconfigure.OpenSearchRestHighLevelClientConfigurations.RestHighLevelClientConfiguration; 10 | import org.springframework.boot.autoconfigure.AutoConfiguration; 11 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 13 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 14 | import org.springframework.context.annotation.Import; 15 | 16 | /** 17 | * {@link EnableAutoConfiguration Auto-configuration} for OpenSearch REST High Level client. 18 | */ 19 | @AutoConfiguration(after = OpenSearchRestClientAutoConfiguration.class) 20 | @ConditionalOnClass(RestHighLevelClient.class) 21 | @EnableConfigurationProperties(OpenSearchProperties.class) 22 | @Import({RestHighLevelClientConfiguration.class}) 23 | public class OpenSearchRestHighLevelClientAutoConfiguration {} 24 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexElasticsearchRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.complex.custommethod.autowiring; 17 | 18 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 19 | 20 | /** 21 | * @author Artur Konczak 22 | */ 23 | public interface ComplexElasticsearchRepository 24 | extends ElasticsearchRepository, 25 | ComplexElasticsearchRepositoryCustom { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/CdiProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.cdi; 17 | 18 | import java.util.Optional; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | 22 | /** 23 | * @author Mohsin Husen 24 | * @author Oliver Gierke 25 | * @author Mark Paluch 26 | * @author Christoph Strobl 27 | */ 28 | public interface CdiProductRepository extends CrudRepository { 29 | 30 | @Override 31 | Optional findById(String id); 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/org/springframework/data/elasticsearch/client/search-ok-scroll.json: -------------------------------------------------------------------------------- 1 | { 2 | "took": 52, 3 | "timed_out": false, 4 | "_scroll_id": "DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAAHFndhSE1uNUlLUXhXb1ZvQTNqOHNrMWcAAAAAAAAABhZ3YUhNbjVJS1F4V29Wb0EzajhzazFnAAAAAAAAAAgWd2FITW41SUtReFdvVm9BM2o4c2sxZwAAAAAAAAAJFndhSE1uNUlLUXhXb1ZvQTNqOHNrMWcAAAAAAAAAChZ3YUhNbjVJS1F4V29Wb0EzajhzazFn", 5 | "_shards": { 6 | "total": 5, 7 | "successful": 5, 8 | "skipped": 0, 9 | "failed": 0 10 | }, 11 | "hits": { 12 | "total": 100, 13 | "max_score": 0.2876821, 14 | "hits": [ 15 | { 16 | "_index": "twitter", 17 | "_type": "doc", 18 | "_id": "2", 19 | "_score": 0.2876821, 20 | "_source": { 21 | "user": "kimchy", 22 | "post_date": "2009-11-15T14:12:12", 23 | "message": "Another tweet, will it be indexed?" 24 | } 25 | }, 26 | { 27 | "_index": "twitter", 28 | "_type": "doc", 29 | "_id": "1", 30 | "_score": 0.2876821, 31 | "_source": { 32 | "user": "kimchy", 33 | "post_date": "2009-11-15T13:12:00", 34 | "message": "Trying out Elasticsearch, so far so good?" 35 | } 36 | } 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/cluster/ClusterOperationsReactiveOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.opensearch.data.client.core.cluster; 17 | 18 | import org.opensearch.data.client.junit.jupiter.ReactiveOpenSearchTemplateConfiguration; 19 | import org.springframework.data.elasticsearch.core.cluster.ClusterOperationsReactiveIntegrationTests; 20 | import org.springframework.test.context.ContextConfiguration; 21 | 22 | @ContextConfiguration(classes = { ReactiveOpenSearchTemplateConfiguration.class }) 23 | public class ClusterOperationsReactiveOSCIntegrationTests 24 | extends ClusterOperationsReactiveIntegrationTests {} 25 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/routing/RoutingOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.routing; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.routing.RoutingIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {RoutingOSCIntegrationTests.Config.class}) 21 | public class RoutingOSCIntegrationTests extends RoutingIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("routing-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/SourceFilterOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.SourceFilterIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {SourceFilterOSCIntegrationTests.Config.class}) 21 | public class SourceFilterOSCIntegrationTests extends SourceFilterIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("source-filter-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/data/ReactiveOpenSearchRepositoriesAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.spring.boot.autoconfigure.data; 2 | 3 | import org.opensearch.data.client.osc.ReactiveOpenSearchClient; 4 | import org.springframework.boot.autoconfigure.AutoConfiguration; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 8 | import org.springframework.context.annotation.Import; 9 | import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; 10 | import org.springframework.data.elasticsearch.repository.support.ReactiveElasticsearchRepositoryFactoryBean; 11 | import reactor.core.publisher.Mono; 12 | 13 | @AutoConfiguration 14 | @ConditionalOnClass({ ReactiveOpenSearchClient.class, ReactiveElasticsearchRepository.class, Mono.class }) 15 | @ConditionalOnProperty(prefix = "spring.data.elasticsearch.repositories", name = "enabled", havingValue = "true", matchIfMissing = true) 16 | @ConditionalOnMissingBean(ReactiveElasticsearchRepositoryFactoryBean.class) 17 | @Import(ReactiveOpenSearchRepositoriesRegistrar.class) 18 | public class ReactiveOpenSearchRepositoriesAutoConfiguration { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/routing/RoutingORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.routing; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.routing.RoutingIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {RoutingORHLCIntegrationTests.Config.class}) 21 | public class RoutingORHLCIntegrationTests extends RoutingIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("routing-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/SourceFilterORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.SourceFilterIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {SourceFilterORHLCIntegrationTests.Config.class}) 21 | public class SourceFilterORHLCIntegrationTests extends SourceFilterIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("source-filter-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/event/CallbackOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.event; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.event.CallbackIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {CallbackOSCIntegrationTests.Config.class}) 21 | class CallbackOSCIntegrationTests extends CallbackIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class, CallbackIntegrationTests.Config.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("callback-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/query/CriteriaQueryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.query; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.query.CriteriaQueryIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {CriteriaQueryOSCIntegrationTests.Config.class}) 21 | public class CriteriaQueryOSCIntegrationTests extends CriteriaQueryIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("criteria-query-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/PersonDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.elasticsearch.repositories.cdi; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.inject.Qualifier; 25 | 26 | /** 27 | * @author Mark Paluch 28 | * @see DATAES-234 29 | */ 30 | @Qualifier 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) 33 | public @interface PersonDB { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/ReactiveReindexOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.junit.jupiter.ReactiveOpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.ReactiveReindexIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = { ReactiveReindexOSCIntegrationTests.Config.class }) 21 | public class ReactiveReindexOSCIntegrationTests extends ReactiveReindexIntegrationTests { 22 | 23 | @Configuration 24 | @Import({ ReactiveOpenSearchTemplateConfiguration.class }) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("reactive-reindex-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/event/CallbackORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.event; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.event.CallbackIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {CallbackORHLCIntegrationTests.Config.class}) 21 | class CallbackORHLCIntegrationTests extends CallbackIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class, CallbackIntegrationTests.Config.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("callback-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/query/CriteriaQueryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.query; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.query.CriteriaQueryIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {CriteriaQueryORHLCIntegrationTests.Config.class}) 21 | public class CriteriaQueryORHLCIntegrationTests extends CriteriaQueryIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("criteria-query-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/indices/IndexOperationsOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.indices; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.indices.IndexOperationsIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {IndexOperationsOSCIntegrationTests.Config.class}) 21 | public class IndexOperationsOSCIntegrationTests extends IndexOperationsIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("indexoperations-es7"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/OtherQualifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.elasticsearch.repositories.cdi; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | import jakarta.inject.Qualifier; 25 | 26 | /** 27 | * @author Mark Paluch 28 | * @see DATAES-234 29 | */ 30 | @Qualifier 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) 33 | public @interface OtherQualifier { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/geohash/GeometryValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils.geohash; 17 | 18 | /** 19 | * /** Code copied from Elasticsearch 7.10, Apache License V2 20 | * https://github.com/elastic/elasticsearch/blob/7.10/libs/geo/src/main/java/org/elasticsearch/geometry/utils/GeometryValidator.java 21 | *
22 | *
23 | * Generic geometry validator that can be used by the parser to verify the validity of the parsed geometry 24 | */ 25 | public interface GeometryValidator { 26 | 27 | /** 28 | * Validates the geometry and throws IllegalArgumentException if the geometry is not valid 29 | */ 30 | void validate(Geometry geometry); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/indices/IndexOperationsORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.indices; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.indices.IndexOperationsIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {IndexOperationsORHLCIntegrationTests.Config.class}) 21 | public class IndexOperationsORHLCIntegrationTests extends IndexOperationsIntegrationTests { 22 | 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("indexoperations-es7"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/IntegrationtestEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.junit.jupiter; 17 | 18 | /** 19 | * @author Peter-Josef Meisch 20 | */ 21 | public enum IntegrationtestEnvironment { 22 | 23 | ELASTICSEARCH, OPENSEARCH, UNDEFINED; 24 | 25 | public static final String SYSTEM_PROPERTY = "sde.integration-test.environment"; 26 | 27 | public static IntegrationtestEnvironment get() { 28 | 29 | String property = System.getProperty(SYSTEM_PROPERTY, "elasticsearch"); 30 | return switch (property.toUpperCase()) { 31 | case "ELASTICSEARCH" -> ELASTICSEARCH; 32 | case "OPENSEARCH" -> OPENSEARCH; 33 | default -> UNDEFINED; 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/data/ReactiveOpenSearchRepositoriesRegistrar.java: -------------------------------------------------------------------------------- 1 | package org.opensearch.spring.boot.autoconfigure.data; 2 | 3 | import java.lang.annotation.Annotation; 4 | import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport; 5 | import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories; 6 | import org.springframework.data.elasticsearch.repository.config.ReactiveElasticsearchRepositoryConfigurationExtension; 7 | import org.springframework.data.repository.config.RepositoryConfigurationExtension; 8 | 9 | class ReactiveOpenSearchRepositoriesRegistrar extends AbstractRepositoryConfigurationSourceSupport { 10 | 11 | @Override 12 | protected Class getAnnotation() { 13 | return EnableReactiveElasticsearchRepositories.class; 14 | } 15 | 16 | @Override 17 | protected Class getConfiguration() { 18 | return EnableOpenSearchRepositoriesConfiguration.class; 19 | } 20 | 21 | @Override 22 | protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() { 23 | return new ReactiveElasticsearchRepositoryConfigurationExtension(); 24 | } 25 | 26 | @EnableReactiveElasticsearchRepositories 27 | private static final class EnableOpenSearchRepositoriesConfiguration { 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/publish-snapshots.yml: -------------------------------------------------------------------------------- 1 | name: Publish snapshots to maven 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build-and-publish-snapshots: 10 | if: github.repository == 'opensearch-project/spring-data-opensearch' 11 | runs-on: ubuntu-latest 12 | permissions: 13 | id-token: write 14 | contents: write 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Set up JDK 21 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: 21 21 | distribution: 'temurin' 22 | - name: Load secret 23 | uses: 1password/load-secrets-action@v2 24 | with: 25 | # Export loaded secrets as environment variables 26 | export-env: true 27 | env: 28 | OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} 29 | MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo 30 | MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role 31 | - name: Configure AWS credentials 32 | uses: aws-actions/configure-aws-credentials@v5 33 | with: 34 | role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }} 35 | aws-region: us-east-1 36 | - name: publish snapshots to Apache Maven repositories 37 | run: | 38 | ./gradlew --no-daemon publishPublishMavenPublicationToSnapshotsRepository 39 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/ReactiveSearchTemplateOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.junit.jupiter.ReactiveOpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.ReactiveSearchTemplateIntegrationTests; 17 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = ReactiveSearchTemplateOSCIntegrationTests.Config.class) 21 | public class ReactiveSearchTemplateOSCIntegrationTests extends ReactiveSearchTemplateIntegrationTests { 22 | 23 | @Configuration 24 | @Import({ ReactiveOpenSearchTemplateConfiguration.class }) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("reactive-searchtemplate-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexElasticsearchRepositoryManualWiring.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.repositories.complex.custommethod.manualwiring; 17 | 18 | import org.springframework.data.elasticsearch.repositories.complex.custommethod.autowiring.ComplexElasticsearchRepositoryCustom; 19 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 20 | 21 | /** 22 | * @author Artur Konczak 23 | */ 24 | public interface ComplexElasticsearchRepositoryManualWiring 25 | extends ElasticsearchRepository, 26 | ComplexElasticsearchRepositoryCustom { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/geohash/Geometry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils.geohash; 17 | 18 | /** 19 | * Code copied from Elasticsearch 7.10, Apache License V2 20 | * https://github.com/elastic/elasticsearch/blob/7.10/libs/geo/src/main/java/org/elasticsearch/geometry/Geometry.java 21 | *
22 | *
23 | * Base class for all Geometry objects supported by elasticsearch 24 | */ 25 | public interface Geometry { 26 | 27 | ShapeType type(); 28 | 29 | T visit(GeometryVisitor visitor) throws E; 30 | 31 | boolean isEmpty(); 32 | 33 | default boolean hasZ() { 34 | return false; 35 | } 36 | 37 | default boolean hasAlt() { 38 | return hasZ(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/junit/jupiter/IntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.junit.jupiter; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | import org.junit.jupiter.api.Tag; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | 26 | /** 27 | * Wraps the {@link SpringDataElasticsearchExtension}. 28 | * 29 | * @author Peter-Josef Meisch 30 | */ 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Target(ElementType.TYPE) 33 | @ExtendWith(SpringDataElasticsearchExtension.class) 34 | @Tag(Tags.INTEGRATION_TEST) 35 | public @interface IntegrationTest { 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/geo/GeoJsonOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.geo; 11 | 12 | import org.junit.jupiter.api.DisplayName; 13 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.Import; 17 | import org.springframework.data.elasticsearch.core.geo.GeoJsonIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {GeoJsonOSCIntegrationTests.Config.class}) 22 | @DisplayName("GeoJson integration test with OpenSearchClient") 23 | public class GeoJsonOSCIntegrationTests extends GeoJsonIntegrationTests { 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | static class Config { 27 | @Bean 28 | IndexNameProvider indexNameProvider() { 29 | return new IndexNameProvider("geojson-integration-os"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/main/java/org/opensearch/data/example/rest/MarketplaceRestController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.rest; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | import org.opensearch.data.example.model.Product; 11 | import org.opensearch.data.example.repository.MarketplaceRepository; 12 | import org.springframework.http.MediaType; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestParam; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | @RestController 19 | @RequestMapping("/marketplace") 20 | public class MarketplaceRestController { 21 | private final MarketplaceRepository repository; 22 | 23 | public MarketplaceRestController(MarketplaceRepository repository) { 24 | this.repository = repository; 25 | } 26 | 27 | @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE) 28 | public List search( 29 | @RequestParam(value = "name", required = false, defaultValue = "") String name, 30 | @RequestParam(value = "price", required = false, defaultValue = "0.0") BigDecimal price) { 31 | return repository.findByNameLikeAndPriceGreaterThan(name, price); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/geo/GeoJsonORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.geo; 11 | 12 | import org.junit.jupiter.api.DisplayName; 13 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.Import; 17 | import org.springframework.data.elasticsearch.core.geo.GeoJsonIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {GeoJsonORHLCIntegrationTests.Config.class}) 22 | @DisplayName("GeoJson integration test with RestHighLevelClient") 23 | public class GeoJsonORHLCIntegrationTests extends GeoJsonIntegrationTests { 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | static class Config { 27 | @Bean 28 | IndexNameProvider indexNameProvider() { 29 | return new IndexNameProvider("geojson-integration-os"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/IdGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | /** 21 | * Class to provide sequential IDs. Uses an integer, 2^31 -1 values should be enough for the test runs. 22 | * 23 | * @author Peter-Josef Meisch 24 | */ 25 | public final class IdGenerator { 26 | 27 | private static final AtomicInteger NEXT = new AtomicInteger(); 28 | 29 | private IdGenerator() {} 30 | 31 | public static int nextIdAsInt() { 32 | return NEXT.incrementAndGet(); 33 | } 34 | 35 | public static double nextIdAsDouble() { 36 | return NEXT.incrementAndGet(); 37 | } 38 | 39 | public static String nextIdAsString() { 40 | return "" + nextIdAsInt(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/config/notnested/EnableRepositoriesOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.config.notnested; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.config.notnested.EnableRepositoriesIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | 20 | public class EnableRepositoriesOSCIntegrationTests extends EnableRepositoriesIntegrationTests { 21 | 22 | @Configuration 23 | @Import({OpenSearchTemplateConfiguration.class}) 24 | @EnableElasticsearchRepositories(basePackages = {"org.springframework.data.elasticsearch.config.notnested"}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("repositories-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/main/java/org/opensearch/data/example/rest/MarketplaceRestController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.rest; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | import org.opensearch.data.example.model.Product; 11 | import org.opensearch.data.example.repository.MarketplaceRepository; 12 | import org.springframework.http.MediaType; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestParam; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | @RestController 19 | @RequestMapping("/marketplace") 20 | public class MarketplaceRestController { 21 | private final MarketplaceRepository repository; 22 | 23 | public MarketplaceRestController(MarketplaceRepository repository) { 24 | this.repository = repository; 25 | } 26 | 27 | @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE) 28 | public List search( 29 | @RequestParam(value = "name", required = false, defaultValue = "") String name, 30 | @RequestParam(value = "price", required = false, defaultValue = "0.0") BigDecimal price) { 31 | return repository.findByNameLikeAndPriceGreaterThan(name, price); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/config/notnested/EnableRepositoriesORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.config.notnested; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.config.notnested.EnableRepositoriesIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | 20 | public class EnableRepositoriesORHLCIntegrationTests extends EnableRepositoriesIntegrationTests { 21 | 22 | @Configuration 23 | @Import({OpenSearchRestTemplateConfiguration.class}) 24 | @EnableElasticsearchRepositories(basePackages = {"org.springframework.data.elasticsearch.config.notnested"}) 25 | static class Config { 26 | @Bean 27 | IndexNameProvider indexNameProvider() { 28 | return new IndexNameProvider("repositories-os"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/IndexInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils; 17 | 18 | import org.springframework.data.elasticsearch.core.IndexOperations; 19 | 20 | /** 21 | * Utility to initialize indexes. 22 | * 23 | * @author Peter-Josef Meisch 24 | */ 25 | public class IndexInitializer { 26 | 27 | private IndexInitializer() {} 28 | 29 | /** 30 | * Initialize a fresh index with mappings for {@link Class}. Drops the index if it exists before creation. 31 | * 32 | * @param indexOperations 33 | */ 34 | public static void init(IndexOperations indexOperations) { 35 | indexOperations.delete(); 36 | indexOperations.create(); 37 | indexOperations.putMapping(indexOperations.createMapping()); 38 | indexOperations.refresh(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/DefaultClusterOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.orhlc; 11 | 12 | import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; 13 | import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; 14 | import org.opensearch.client.RequestOptions; 15 | import org.springframework.data.elasticsearch.core.cluster.ClusterHealth; 16 | import org.springframework.data.elasticsearch.core.cluster.ClusterOperations; 17 | 18 | /** 19 | * Default implementation of {@link ClusterOperations} using the {@link OpenSearchRestTemplate}. 20 | * @since 0.1 21 | */ 22 | class DefaultClusterOperations implements ClusterOperations { 23 | 24 | private final OpenSearchRestTemplate template; 25 | 26 | DefaultClusterOperations(OpenSearchRestTemplate template) { 27 | this.template = template; 28 | } 29 | 30 | @Override 31 | public ClusterHealth health() { 32 | 33 | ClusterHealthResponse clusterHealthResponse = 34 | template.execute(client -> client.cluster().health(new ClusterHealthRequest(), RequestOptions.DEFAULT)); 35 | return ResponseConverter.clusterHealth(clusterHealthResponse); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/IndexNameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils; 17 | 18 | /** 19 | * Class providing an index name witInCo 20 | * 21 | * @author Peter-Josef Meisch 22 | */ 23 | public class IndexNameProvider { 24 | private final String prefix; 25 | private int idx = -1; 26 | private String indexName; 27 | 28 | public IndexNameProvider() { 29 | this("index-default"); 30 | } 31 | 32 | public IndexNameProvider(String prefix) { 33 | this.prefix = prefix; 34 | increment(); 35 | } 36 | 37 | public void increment() { 38 | indexName = prefix + '-' + ++idx; 39 | } 40 | 41 | public String indexName() { 42 | return indexName; 43 | } 44 | 45 | /** 46 | * @since 4.4 47 | */ 48 | public String getPrefix() { 49 | return prefix; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/Aggregation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.opensearch.data.client.osc; 17 | 18 | import org.opensearch.client.opensearch._types.aggregations.Aggregate; 19 | 20 | /** 21 | * Class to combine an OpenSearch {@link Aggregate} with its name. Necessary as the OpenSearch Aggregate does not know its name. 22 | * 23 | * @author Peter-Josef Meisch 24 | * @since 4.4 25 | */ 26 | public record Aggregation(String name, Aggregate aggregate) { 27 | 28 | /** 29 | * @deprecated Use {@link #name()} instead 30 | */ 31 | @Deprecated 32 | public String getName() { 33 | return name(); 34 | } 35 | 36 | /** 37 | * @deprecated Use {@link #aggregate()} instead 38 | */ 39 | @Deprecated 40 | public Aggregate getAggregate() { 41 | return aggregate(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/main/java/org/opensearch/data/example/rest/MarketplaceRestController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.rest; 7 | 8 | import java.math.BigDecimal; 9 | import org.opensearch.data.example.model.Product; 10 | import org.opensearch.data.example.repository.ReactiveMarketplaceRepository; 11 | import org.springframework.http.MediaType; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import reactor.core.publisher.Flux; 17 | 18 | @RestController 19 | @RequestMapping("/marketplace") 20 | public class MarketplaceRestController { 21 | private final ReactiveMarketplaceRepository repository; 22 | 23 | public MarketplaceRestController(ReactiveMarketplaceRepository repository) { 24 | this.repository = repository; 25 | } 26 | 27 | @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE) 28 | public Flux search( 29 | @RequestParam(value = "name", required = false, defaultValue = "") String name, 30 | @RequestParam(value = "price", required = false, defaultValue = "0.0") BigDecimal price) { 31 | return repository.findByNameLikeAndPriceGreaterThan(name, price); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/config/notnested/SampleElasticsearchRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.config.notnested; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 21 | 22 | /** 23 | * @author Rizwan Idrees 24 | * @author Mohsin Husen 25 | * @author Christoph Strobl 26 | */ 27 | public interface SampleElasticsearchRepository 28 | extends ElasticsearchRepository { 29 | 30 | long deleteSampleEntityById(String id); 31 | 32 | List deleteByAvailable(boolean available); 33 | 34 | List deleteByMessage(String message); 35 | 36 | void deleteByType(String type); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | %d %5p %c - %m%n 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/paginating/SearchAfterOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.paginating; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.paginating.SearchAfterIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SearchAfterOSCIntegrationTests.Config.class}) 22 | public class SearchAfterOSCIntegrationTests extends SearchAfterIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories(considerNestedRepositories = true) 27 | static class Config { 28 | @Bean 29 | IndexNameProvider indexNameProvider() { 30 | return new IndexNameProvider("search-after-os"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/paginating/SearchAfterORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core.paginating; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.core.paginating.SearchAfterIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SearchAfterORHLCIntegrationTests.Config.class}) 22 | public class SearchAfterORHLCIntegrationTests extends SearchAfterIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories(considerNestedRepositories = true) 27 | static class Config { 28 | @Bean 29 | IndexNameProvider indexNameProvider() { 30 | return new IndexNameProvider("search-after-os"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/config/notnested/SampleUUIDKeyedElasticsearchRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.config.notnested; 17 | 18 | import java.util.List; 19 | import java.util.UUID; 20 | 21 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 22 | 23 | /** 24 | * @author Gad Akuka 25 | * @author Christoph Strobl 26 | */ 27 | interface SampleUUIDKeyedElasticsearchRepository 28 | extends ElasticsearchRepository { 29 | 30 | long deleteSampleEntityUUIDKeyedById(UUID id); 31 | 32 | List deleteByAvailable(boolean available); 33 | 34 | List deleteByMessage(String message); 35 | 36 | void deleteByType(String type); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/data/OpenSearchDataAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure.data; 7 | 8 | import org.opensearch.data.client.orhlc.OpenSearchRestTemplate; 9 | import org.opensearch.data.client.osc.OpenSearchTemplate; 10 | import org.opensearch.spring.boot.autoconfigure.OpenSearchClientAutoConfiguration; 11 | import org.opensearch.spring.boot.autoconfigure.OpenSearchRestClientAutoConfiguration; 12 | import org.springframework.boot.autoconfigure.AutoConfiguration; 13 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 15 | import org.springframework.context.annotation.Import; 16 | 17 | /** 18 | * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's OpenSearch support. 19 | * 20 | * Adaptation of the {@link org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfiguration} to 21 | * the needs of OpenSearch. 22 | */ 23 | @AutoConfiguration(after = {OpenSearchClientAutoConfiguration.class, OpenSearchRestClientAutoConfiguration.class}) 24 | @ConditionalOnClass({OpenSearchRestTemplate.class, OpenSearchTemplate.class}) 25 | @Import({OpenSearchDataConfiguration.BaseConfiguration.class, OpenSearchDataConfiguration.JavaClientConfiguration.class, 26 | OpenSearchDataConfiguration.ReactiveRestClientConfiguration.class}) 27 | public class OpenSearchDataAutoConfiguration {} 28 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/OpenSearchClientAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | package org.opensearch.spring.boot.autoconfigure; 6 | 7 | import org.opensearch.client.RestClient; 8 | import org.opensearch.client.opensearch.OpenSearchClient; 9 | import org.opensearch.spring.boot.autoconfigure.OpenSearchClientConfigurations.JsonpMapperConfiguration; 10 | import org.opensearch.spring.boot.autoconfigure.OpenSearchClientConfigurations.OpenSearchClientConfiguration; 11 | import org.opensearch.spring.boot.autoconfigure.OpenSearchClientConfigurations.OpenSearchTransportConfiguration; 12 | import org.springframework.boot.autoconfigure.AutoConfiguration; 13 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 15 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 16 | import org.springframework.context.annotation.Import; 17 | 18 | /** 19 | * {@link EnableAutoConfiguration Auto-configuration} for OpenSearch's Java client. 20 | */ 21 | @AutoConfiguration(after = { OpenSearchRestClientAutoConfiguration.class }, 22 | afterName = { "org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration" }) 23 | @ConditionalOnBean(RestClient.class) 24 | @ConditionalOnClass(OpenSearchClient.class) 25 | @Import({ JsonpMapperConfiguration.class, OpenSearchTransportConfiguration.class, OpenSearchClientConfiguration.class }) 26 | public class OpenSearchClientAutoConfiguration { 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/springframework/data/elasticsearch/utils/geohash/ShapeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.elasticsearch.utils.geohash; 17 | 18 | import java.util.Locale; 19 | 20 | /** 21 | * Code copied from Elasticsearch 7.10, Apache License V2 22 | * https://github.com/elastic/elasticsearch/blob/7.10/libs/geo/src/main/java/org/elasticsearch/geometry/ShapeType.java 23 | *
24 | *
25 | * Shape types supported by elasticsearch 26 | */ 27 | public enum ShapeType { 28 | POINT, // 29 | MULTIPOINT, // 30 | LINESTRING, // 31 | MULTILINESTRING, // 32 | POLYGON, // 33 | MULTIPOLYGON, // 34 | GEOMETRYCOLLECTION, // 35 | LINEARRING, // not serialized by itself in WKT or WKB 36 | ENVELOPE, // not part of the actual WKB spec 37 | CIRCLE; // not part of the actual WKB spec 38 | 39 | public static ShapeType forName(String shapeName) { 40 | return ShapeType.valueOf(shapeName.toUpperCase(Locale.ROOT)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/ReactivePointInTimeOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.EnabledIfOpenSearchVersion; 13 | import org.opensearch.data.client.junit.jupiter.ReactiveOpenSearchTemplateConfiguration; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.context.annotation.Configuration; 16 | import org.springframework.context.annotation.Import; 17 | import org.springframework.data.elasticsearch.core.ReactivePointInTimeIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = ReactivePointInTimeOSCIntegrationTests.Config.class) 22 | @EnabledIfOpenSearchVersion( 23 | onOrAfter = "2.3.0", 24 | reason = "https://github.com/opensearch-project/OpenSearch/issues/1147") 25 | public class ReactivePointInTimeOSCIntegrationTests extends ReactivePointInTimeIntegrationTests { 26 | 27 | @Configuration 28 | @Import({ ReactiveOpenSearchTemplateConfiguration.class }) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("reactive-point-in-time-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/dynamicindex/DynamicIndexEntityOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.dynamicindex; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.dynamicindex.DynamicIndexEntityIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {DynamicIndexEntityOSCIntegrationTests.Config.class}) 21 | public class DynamicIndexEntityOSCIntegrationTests extends DynamicIndexEntityIntegrationTests { 22 | @Configuration 23 | @Import({OpenSearchTemplateConfiguration.class}) 24 | @EnableElasticsearchRepositories( 25 | basePackages = {"org.springframework.data.elasticsearch.repositories.dynamicindex"}, 26 | considerNestedRepositories = true) 27 | static class Config { 28 | @Bean 29 | public IndexNameProvider indexNameProvider() { 30 | return new IndexNameProvider(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/spel/SpELEntityOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.spel; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.spel.SpELEntityIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SpELEntityOSCIntegrationTests.Config.class}) 22 | public class SpELEntityOSCIntegrationTests extends SpELEntityIntegrationTests { 23 | @Configuration 24 | @Import(OpenSearchTemplateConfiguration.class) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.spel"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("spel-entity-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/test/java/org/opensearch/data/example/repository/MarketplaceRepositoryIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import java.time.Duration; 11 | import org.junit.jupiter.api.Tag; 12 | import org.junit.jupiter.api.Test; 13 | import org.opensearch.spring.boot.autoconfigure.test.DataOpenSearchTest; 14 | import org.opensearch.testcontainers.OpenSearchContainer; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.testcontainers.junit.jupiter.Container; 19 | import org.testcontainers.junit.jupiter.Testcontainers; 20 | 21 | @Testcontainers(disabledWithoutDocker = true) 22 | @DataOpenSearchTest 23 | @EnableElasticsearchRepositories(basePackageClasses = MarketplaceRepository.class) 24 | @Tag("integration-test") 25 | public class MarketplaceRepositoryIntegrationTests { 26 | @Container 27 | @ServiceConnection 28 | static final OpenSearchContainer opensearch = new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0") 29 | .withStartupAttempts(5) 30 | .withStartupTimeout(Duration.ofMinutes(2)); 31 | 32 | @Test 33 | void testMarketplaceRepository(@Autowired MarketplaceRepository repository) { 34 | assertThat(repository.findAll()).isEmpty(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/dynamicindex/DynamicIndexEntityORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.dynamicindex; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.dynamicindex.DynamicIndexEntityIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.test.context.ContextConfiguration; 19 | 20 | @ContextConfiguration(classes = {DynamicIndexEntityORHLCIntegrationTests.Config.class}) 21 | public class DynamicIndexEntityORHLCIntegrationTests extends DynamicIndexEntityIntegrationTests { 22 | @Configuration 23 | @Import({OpenSearchRestTemplateConfiguration.class}) 24 | @EnableElasticsearchRepositories( 25 | basePackages = {"org.springframework.data.elasticsearch.repositories.dynamicindex"}, 26 | considerNestedRepositories = true) 27 | static class Config { 28 | @Bean 29 | public IndexNameProvider indexNameProvider() { 30 | return new IndexNameProvider(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/spel/SpELEntityORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.spel; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.spel.SpELEntityIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SpELEntityORHLCIntegrationTests.Config.class}) 22 | public class SpELEntityORHLCIntegrationTests extends SpELEntityIntegrationTests { 23 | @Configuration 24 | @Import(OpenSearchRestTemplateConfiguration.class) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.spel"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("spel-entity-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/test/java/org/opensearch/data/example/repository/MarketplaceRepositoryIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | import java.time.Duration; 11 | import org.junit.jupiter.api.Tag; 12 | import org.junit.jupiter.api.Test; 13 | import org.opensearch.spring.boot.autoconfigure.test.DataOpenSearchTest; 14 | import org.opensearch.testcontainers.OpenSearchContainer; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.testcontainers.junit.jupiter.Container; 19 | import org.testcontainers.junit.jupiter.Testcontainers; 20 | 21 | @Testcontainers(disabledWithoutDocker = true) 22 | @DataOpenSearchTest 23 | @EnableElasticsearchRepositories(basePackageClasses = MarketplaceRepository.class) 24 | @Tag("integration-test") 25 | public class MarketplaceRepositoryIntegrationTests { 26 | @Container 27 | @ServiceConnection 28 | static final OpenSearchContainer opensearch = new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0") 29 | .withStartupAttempts(5) 30 | .withStartupTimeout(Duration.ofMinutes(2)); 31 | 32 | @Test 33 | void testMarketplaceRepository(@Autowired MarketplaceRepository repository) { 34 | assertThat(repository.findAll()).isEmpty(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/immutable/ImmutableRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.immutable; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.immutable.ImmutableRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = ImmutableRepositoryOSCIntegrationTests.Config.class) 22 | public class ImmutableRepositoryOSCIntegrationTests extends ImmutableRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.immutable"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("immutable-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/geo/GeoRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.geo; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.geo.GeoRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {GeoRepositoryOSCIntegrationTests.Config.class}) 22 | public class GeoRepositoryOSCIntegrationTests extends GeoRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.geo"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("geo-repository-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/geo/GeoRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.geo; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.geo.GeoRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {GeoRepositoryORHLCIntegrationTests.Config.class}) 22 | public class GeoRepositoryORHLCIntegrationTests extends GeoRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.geo"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("geo-repository-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/immutable/ImmutableRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.immutable; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.immutable.ImmutableRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = ImmutableRepositoryORHLCIntegrationTests.Config.class) 22 | public class ImmutableRepositoryORHLCIntegrationTests extends ImmutableRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.immutable"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("immutable-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/nestedobject/InnerObjectOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.nestedobject; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.nestedobject.InnerObjectIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {InnerObjectOSCIntegrationTests.Config.class}) 22 | public class InnerObjectOSCIntegrationTests extends InnerObjectIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.nestedobject"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("inner-object-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/main/java/org/opensearch/data/client/osc/ReactiveClusterTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.osc; 11 | 12 | import org.opensearch.client.opensearch.cluster.HealthRequest; 13 | import org.opensearch.client.opensearch.cluster.HealthResponse; 14 | import org.opensearch.client.transport.OpenSearchTransport; 15 | import org.springframework.data.elasticsearch.core.cluster.ClusterHealth; 16 | import org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations; 17 | import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; 18 | import reactor.core.publisher.Mono; 19 | 20 | /** 21 | * Reactive cluster template 22 | */ 23 | public class ReactiveClusterTemplate 24 | extends ReactiveChildTemplate 25 | implements ReactiveClusterOperations { 26 | 27 | public ReactiveClusterTemplate(ReactiveOpenSearchClusterClient client, 28 | ElasticsearchConverter elasticsearchConverter) { 29 | super(client, elasticsearchConverter); 30 | } 31 | 32 | @Override 33 | public Mono health() { 34 | 35 | HealthRequest healthRequest = requestConverter.clusterHealthRequest(); 36 | Mono healthResponse = Mono.from(execute(client -> client.health(healthRequest))); 37 | return healthResponse.map(responseConverter::clusterHealth); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/ReindexOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | 13 | import static org.opensearch.data.client.osc.Queries.termQueryAsQuery; 14 | 15 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 16 | import org.opensearch.data.client.osc.NativeQuery; 17 | import org.springframework.context.annotation.Bean; 18 | import org.springframework.context.annotation.Configuration; 19 | import org.springframework.context.annotation.Import; 20 | import org.springframework.data.elasticsearch.core.ReindexIntegrationTests; 21 | import org.springframework.data.elasticsearch.core.query.Query; 22 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 23 | import org.springframework.test.context.ContextConfiguration; 24 | 25 | @ContextConfiguration(classes = {ReindexOSCIntegrationTests.Config.class}) 26 | public class ReindexOSCIntegrationTests extends ReindexIntegrationTests { 27 | 28 | @Configuration 29 | @Import({OpenSearchTemplateConfiguration.class}) 30 | static class Config { 31 | @Bean 32 | IndexNameProvider indexNameProvider() { 33 | return new IndexNameProvider("reindex-os"); 34 | } 35 | } 36 | 37 | @Override 38 | protected Query queryForId(String id) { 39 | return NativeQuery.builder().withQuery(termQueryAsQuery("_id", id)).build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/nestedobject/InnerObjectORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.nestedobject; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.nestedobject.InnerObjectIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {InnerObjectORHLCIntegrationTests.Config.class}) 22 | public class InnerObjectORHLCIntegrationTests extends InnerObjectIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.nestedobject"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("inner-object-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/synonym/SynonymRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.synonym; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.synonym.SynonymRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SynonymRepositoryOSCIntegrationTests.Config.class}) 22 | public class SynonymRepositoryOSCIntegrationTests extends SynonymRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.synonym"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("sysnonym-entity-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/synonym/SynonymRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.synonym; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.synonym.SynonymRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {SynonymRepositoryORHLCIntegrationTests.Config.class}) 22 | public class SynonymRepositoryORHLCIntegrationTests extends SynonymRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.synonym"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("sysnonym-entity-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/doubleid/DoubleIDRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.doubleid; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.doubleid.DoubleIDRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {DoubleIDRepositoryOSCIntegrationTests.Config.class}) 22 | public class DoubleIDRepositoryOSCIntegrationTests extends DoubleIDRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repositories.doubleid"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("doubleid-repository-es7"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/integer/IntegerIDRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.integer; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.integer.IntegerIDRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {IntegerIDRepositoryOSCIntegrationTests.Config.class}) 22 | public class IntegerIDRepositoryOSCIntegrationTests extends IntegerIDRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repositories.integer"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("integerid-repository-es7"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repository/support/ElasticsearchRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repository.support; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 17 | import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {ElasticsearchRepositoryOSCIntegrationTests.Config.class}) 22 | public class ElasticsearchRepositoryOSCIntegrationTests extends ElasticsearchRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repository.support"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("repository-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch-starter/src/main/java/org/opensearch/spring/boot/autoconfigure/ReactiveOpenSearchClientAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.spring.boot.autoconfigure; 7 | 8 | import org.opensearch.client.RestClient; 9 | import org.opensearch.client.transport.OpenSearchTransport; 10 | import org.opensearch.data.client.osc.ReactiveOpenSearchClient; 11 | import org.springframework.boot.autoconfigure.AutoConfiguration; 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 14 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 15 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 16 | import org.springframework.context.annotation.Bean; 17 | import org.springframework.context.annotation.Import; 18 | import reactor.core.publisher.Mono; 19 | 20 | @AutoConfiguration(after = OpenSearchClientAutoConfiguration.class) 21 | @ConditionalOnBean(RestClient.class) 22 | @ConditionalOnClass({ OpenSearchTransport.class, Mono.class }) 23 | @EnableConfigurationProperties(OpenSearchProperties.class) 24 | @Import({ OpenSearchClientConfigurations.JsonpMapperConfiguration.class, 25 | OpenSearchClientConfigurations.OpenSearchTransportConfiguration.class }) 26 | public class ReactiveOpenSearchClientAutoConfiguration { 27 | 28 | @Bean 29 | @ConditionalOnMissingBean 30 | @ConditionalOnBean(OpenSearchTransport.class) 31 | ReactiveOpenSearchClient reactiveOpensearchClient(OpenSearchTransport transport) { 32 | return new ReactiveOpenSearchClient(transport); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/doubleid/DoubleIDRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.doubleid; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.doubleid.DoubleIDRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {DoubleIDRepositoryORHLCIntegrationTests.Config.class}) 22 | public class DoubleIDRepositoryORHLCIntegrationTests extends DoubleIDRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repositories.doubleid"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("doubleid-repository-es7"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/integer/IntegerIDRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.integer; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.integer.IntegerIDRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {IntegerIDRepositoryORHLCIntegrationTests.Config.class}) 22 | public class IntegerIDRepositoryORHLCIntegrationTests extends IntegerIDRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repositories.integer"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("integerid-repository-es7"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repository/support/ElasticsearchRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repository.support; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 17 | import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {ElasticsearchRepositoryORHLCIntegrationTests.Config.class}) 22 | public class ElasticsearchRepositoryORHLCIntegrationTests extends ElasticsearchRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchRestTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repository.support"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("repository-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repository/query/valueconverter/ValueConverterOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repository.query.valueconverter; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 17 | import org.springframework.data.elasticsearch.repository.query.valueconverter.ValueConverterIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = { ValueConverterOSCIntegrationTests.Config.class }) 22 | public class ValueConverterOSCIntegrationTests extends ValueConverterIntegrationTests { 23 | 24 | @Configuration 25 | @Import({ OpenSearchTemplateConfiguration.class }) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repository.query.valueconverter"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("valueconverter-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/core/ReindexORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.core; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.opensearch.data.client.orhlc.NativeSearchQueryBuilder; 14 | import org.opensearch.index.query.QueryBuilders; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.context.annotation.Configuration; 17 | import org.springframework.context.annotation.Import; 18 | import org.springframework.data.elasticsearch.core.ReindexIntegrationTests; 19 | import org.springframework.data.elasticsearch.core.query.Query; 20 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 21 | import org.springframework.test.context.ContextConfiguration; 22 | 23 | @ContextConfiguration(classes = {ReindexORHLCIntegrationTests.Config.class}) 24 | public class ReindexORHLCIntegrationTests extends ReindexIntegrationTests { 25 | 26 | @Configuration 27 | @Import({OpenSearchRestTemplateConfiguration.class}) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("reindex-os"); 32 | } 33 | } 34 | 35 | @Override 36 | protected Query queryForId(String id) { 37 | return new NativeSearchQueryBuilder() 38 | .withQuery(QueryBuilders.termQuery("_id", id)) 39 | .build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repository/query/valueconverter/ValueConverterORHLIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repository.query.valueconverter; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 17 | import org.springframework.data.elasticsearch.repository.query.valueconverter.ValueConverterIntegrationTests; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = { ValueConverterORHLIntegrationTests.Config.class }) 22 | public class ValueConverterORHLIntegrationTests extends ValueConverterIntegrationTests { 23 | 24 | @Configuration 25 | @Import({ OpenSearchRestTemplateConfiguration.class }) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repository.query.valueconverter"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("valueconverter-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-gradle/src/main/java/org/opensearch/data/example/service/MarketplaceInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.service; 7 | 8 | import java.math.BigDecimal; 9 | import org.opensearch.data.example.model.Product; 10 | import org.opensearch.data.example.repository.MarketplaceRepository; 11 | import org.springframework.beans.factory.InitializingBean; 12 | import org.springframework.stereotype.Service; 13 | 14 | @Service 15 | public class MarketplaceInitializer implements InitializingBean { 16 | private final MarketplaceRepository repository; 17 | 18 | public MarketplaceInitializer(MarketplaceRepository repository) { 19 | this.repository = repository; 20 | } 21 | 22 | @Override 23 | public void afterPropertiesSet() throws Exception { 24 | repository.save(new Product( 25 | "1", 26 | "Utopia Bedding Bed Pillows", 27 | new BigDecimal(39.99), 28 | 2, 29 | "These professionally finished pillows, with high thread counts, provide great comfort against your skin along with added durability " 30 | + "that easily resists wear and tear to ensure a finished look for your bedroom.", 31 | "Utopia Bedding")); 32 | 33 | repository.save(new Product( 34 | "2", 35 | "Echo Dot Smart speaker", 36 | new BigDecimal(34.99), 37 | 10, 38 | "Our most popular smart speaker with a fabric design. It is our most compact smart speaker that fits perfectly into small spaces.", 39 | "Amazon")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/uuidkeyed/UUIDElasticsearchRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.uuidkeyed; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.uuidkeyed.UUIDElasticsearchRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {UUIDElasticsearchRepositoryOSCIntegrationTests.Config.class}) 22 | public class UUIDElasticsearchRepositoryOSCIntegrationTests extends UUIDElasticsearchRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.uuidkeyed"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("uuid-keyed-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/custommethod/CustomMethodRepositoryOSCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.custommethod; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.custommethod.CustomMethodRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {CustomMethodRepositoryOSCIntegrationTests.Config.class}) 22 | public class CustomMethodRepositoryOSCIntegrationTests extends CustomMethodRepositoryIntegrationTests { 23 | 24 | @Configuration 25 | @Import({OpenSearchTemplateConfiguration.class}) 26 | @EnableElasticsearchRepositories( 27 | basePackages = {"org.springframework.data.elasticsearch.repositories.custommethod"}, 28 | considerNestedRepositories = true) 29 | static class Config { 30 | @Bean 31 | IndexNameProvider indexNameProvider() { 32 | return new IndexNameProvider("custom-method-repository-os"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-opensearch/src/test/java/org/opensearch/data/client/repositories/uuidkeyed/UUIDElasticsearchRepositoryORHLCIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * The OpenSearch Contributors require contributions made to 6 | * this file be licensed under the Apache-2.0 license or a 7 | * compatible open source license. 8 | */ 9 | 10 | package org.opensearch.data.client.repositories.uuidkeyed; 11 | 12 | import org.opensearch.data.client.junit.jupiter.OpenSearchRestTemplateConfiguration; 13 | import org.springframework.context.annotation.Bean; 14 | import org.springframework.context.annotation.Configuration; 15 | import org.springframework.context.annotation.Import; 16 | import org.springframework.data.elasticsearch.repositories.uuidkeyed.UUIDElasticsearchRepositoryIntegrationTests; 17 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 18 | import org.springframework.data.elasticsearch.utils.IndexNameProvider; 19 | import org.springframework.test.context.ContextConfiguration; 20 | 21 | @ContextConfiguration(classes = {UUIDElasticsearchRepositoryORHLCIntegrationTests.Config.class}) 22 | public class UUIDElasticsearchRepositoryORHLCIntegrationTests extends UUIDElasticsearchRepositoryIntegrationTests { 23 | @Configuration 24 | @Import({OpenSearchRestTemplateConfiguration.class}) 25 | @EnableElasticsearchRepositories( 26 | basePackages = {"org.springframework.data.elasticsearch.repositories.uuidkeyed"}, 27 | considerNestedRepositories = true) 28 | static class Config { 29 | @Bean 30 | IndexNameProvider indexNameProvider() { 31 | return new IndexNameProvider("uuid-keyed-os"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-java-client-gradle/src/main/java/org/opensearch/data/example/service/MarketplaceInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.service; 7 | 8 | import java.math.BigDecimal; 9 | import org.opensearch.data.example.model.Product; 10 | import org.opensearch.data.example.repository.MarketplaceRepository; 11 | import org.springframework.beans.factory.InitializingBean; 12 | import org.springframework.stereotype.Service; 13 | 14 | @Service 15 | public class MarketplaceInitializer implements InitializingBean { 16 | private final MarketplaceRepository repository; 17 | 18 | public MarketplaceInitializer(MarketplaceRepository repository) { 19 | this.repository = repository; 20 | } 21 | 22 | @Override 23 | public void afterPropertiesSet() throws Exception { 24 | repository.save(new Product( 25 | "1", 26 | "Utopia Bedding Bed Pillows", 27 | new BigDecimal(39.99), 28 | 2, 29 | "These professionally finished pillows, with high thread counts, provide great comfort against your skin along with added durability " 30 | + "that easily resists wear and tear to ensure a finished look for your bedroom.", 31 | "Utopia Bedding")); 32 | 33 | repository.save(new Product( 34 | "2", 35 | "Echo Dot Smart speaker", 36 | new BigDecimal(34.99), 37 | 10, 38 | "Our most popular smart speaker with a fabric design. It is our most compact smart speaker that fits perfectly into small spaces.", 39 | "Amazon")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-opensearch-examples/spring-boot-reactive-client-gradle/src/test/java/org/opensearch/data/example/repository/MarketplaceRepositoryIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright OpenSearch Contributors. 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | package org.opensearch.data.example.repository; 7 | 8 | import java.time.Duration; 9 | import org.junit.jupiter.api.Tag; 10 | import org.junit.jupiter.api.Test; 11 | import org.opensearch.spring.boot.autoconfigure.test.DataOpenSearchTest; 12 | import org.opensearch.testcontainers.OpenSearchContainer; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 15 | import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories; 16 | import org.testcontainers.junit.jupiter.Container; 17 | import org.testcontainers.junit.jupiter.Testcontainers; 18 | import reactor.test.StepVerifier; 19 | 20 | @Testcontainers(disabledWithoutDocker = true) 21 | @DataOpenSearchTest 22 | @EnableReactiveElasticsearchRepositories(basePackageClasses = ReactiveMarketplaceRepository.class) 23 | @Tag("integration-test") 24 | public class MarketplaceRepositoryIntegrationTests { 25 | @Container 26 | @ServiceConnection 27 | static final OpenSearchContainer opensearch = new OpenSearchContainer<>("opensearchproject/opensearch:3.1.0") 28 | .withStartupAttempts(5) 29 | .withStartupTimeout(Duration.ofMinutes(2)); 30 | 31 | @Test 32 | void testMarketplaceRepository(@Autowired ReactiveMarketplaceRepository repository) { 33 | StepVerifier 34 | .create(repository.findAll()) 35 | .expectComplete() 36 | .verify(Duration.ofSeconds(5)); 37 | } 38 | } 39 | --------------------------------------------------------------------------------