main b5429e319338 cached
104 files
176.7 KB
45.0k tokens
163 symbols
1 requests
Download .txt
Showing preview only (213K chars total). Download the full file or copy to clipboard to get everything.
Repository: dadoonet/spring-elasticsearch
Branch: main
Commit: b5429e319338
Files: 104
Total size: 176.7 KB

Directory structure:
gitextract_6pq6rnnj/

├── .github/
│   ├── CODEOWNERS
│   ├── dependabot.yml
│   ├── mergify.yml
│   └── workflows/
│       ├── maven.yml
│       └── pr.yml
├── .gitignore
├── .mvn/
│   ├── jvm.config
│   └── maven.config
├── LICENSE
├── NOTICE
├── README.md
├── pom.xml
└── src/
    ├── main/
    │   ├── java/
    │   │   └── fr/
    │   │       └── pilato/
    │   │           └── spring/
    │   │               └── elasticsearch/
    │   │                   ├── ElasticsearchClientFactoryBean.java
    │   │                   ├── SSLUtils.java
    │   │                   └── Tuple.java
    │   └── resources/
    │       └── org/
    │           └── apache/
    │               └── maven/
    │                   └── plugin/
    │                       └── announcement/
    │                           └── announcement.vm
    └── test/
        ├── java/
        │   └── fr/
        │       └── pilato/
        │           └── spring/
        │               └── elasticsearch/
        │                   ├── it/
        │                   │   ├── BaseTest.java
        │                   │   └── annotation/
        │                   │       ├── AbstractAnnotationContextModel.java
        │                   │       └── rest/
        │                   │           ├── AbstractRestAnnotationContextModel.java
        │                   │           ├── RestAppConfig.java
        │                   │           ├── aliases/
        │                   │           │   ├── AliasesTest.java
        │                   │           │   └── AppConfig.java
        │                   │           ├── badclasspath/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── BadClasspath7Test.java
        │                   │           ├── configuration/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── ConfigurationTest.java
        │                   │           ├── customanalyzers/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── CustomAnalyzers12Test.java
        │                   │           ├── indextemplates/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── IndexTemplatesTest.java
        │                   │           ├── indicesalreadyexist/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── IndicesAlreadyExistTest.java
        │                   │           ├── lifecycles/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── LifecyclesTest.java
        │                   │           ├── manualsettings/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── ManualSettingsTest.java
        │                   │           ├── mapping/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingTest.java
        │                   │           ├── mappingconvention/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingConventionTest.java
        │                   │           ├── mappingfailed/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingFailedTest.java
        │                   │           ├── multipleclients/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MultipleClientsTest.java
        │                   │           ├── pipelines/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── PipelinesTest.java
        │                   │           ├── settings13/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── Settings13Test.java
        │                   │           ├── settingsfailed/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── SettingsFailedTest.java
        │                   │           ├── settingsnomapping21/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── SettingsNoMapping21Test.java
        │                   │           ├── shards/
        │                   │           │   └── AppConfig.java
        │                   │           ├── updatesettingsdisabled31/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── UpdateSettingsDisabled31Test.java
        │                   │           └── updatesettingsenabled31/
        │                   │               ├── AppConfig.java
        │                   │               └── UpdateSettings31Test.java
        │                   └── unit/
        │                       └── ClassPathReaderTest.java
        └── resources/
            ├── classpath-reader-test.txt
            ├── es/
            │   └── twitter/
            │       └── _settings.json
            ├── log4j2.xml
            └── models/
                └── root/
                    ├── aliases/
                    │   ├── _aliases.json
                    │   ├── test_1/
                    │   │   └── _settings.json
                    │   ├── test_2/
                    │   │   └── _settings.json
                    │   └── twitter/
                    │       └── _settings.json
                    ├── custom-analyzers-12/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── index-templates/
                    │   └── client/
                    │       ├── _component_templates/
                    │       │   ├── component1.json
                    │       │   └── component2.json
                    │       └── _index_templates/
                    │           └── template_1.json
                    ├── index-with-type/
                    │   └── client/
                    │       └── twitter/
                    │           └── _doc.json
                    ├── indices-already-exist-86/
                    │   └── client/
                    │       ├── badindex/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── lifecycles/
                    │   ├── _index_lifecycles/
                    │   │   └── policy1.json
                    │   └── twitter/
                    │       └── _settings.json
                    ├── manual-settings/
                    │   ├── _aliases.json
                    │   ├── _component_templates/
                    │   │   ├── component1.json
                    │   │   └── component2.json
                    │   ├── _index_templates/
                    │   │   ├── template_1.json
                    │   │   └── template_2.json
                    │   ├── _pipelines/
                    │   │   ├── pipeline1.json
                    │   │   └── pipeline2.json
                    │   └── foobar/
                    │       └── _settings.json
                    ├── mapping/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── mapping-failed/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    ├── multiple-clients/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── no-namespace/
                    │   └── client/
                    │       ├── rss/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── pipelines/
                    │   └── _pipelines/
                    │       └── pipeline1.json
                    ├── plugins/
                    │   └── client/
                    │       └── twitter/
                    │           ├── _doc.json
                    │           └── _settings.json
                    ├── rest-client-namespace/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── settings-13/
                    │   └── client/
                    │       ├── rss/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── settings-failed/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    ├── settings-no-mapping-21/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── shards/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── update-settings-31/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    └── update-settings-disabled-31/
                        ├── client1/
                        │   └── twitter/
                        │       └── _settings.json
                        └── client2/
                            └── twitter/
                                └── _update_settings.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/CODEOWNERS
================================================
# This file is used to define the code owners for the repository.
# Each line is a file pattern followed by one or more GitHub usernames or team names.
# For more information, see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
# The code owners will be automatically requested for review when someone makes changes to the files they own.
# All the modified files will be reviewed by dadoonet.
*       @dadoonet


================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
# Enable version updates for Maven
- package-ecosystem: maven
  directory: "/"
  schedule:
    interval: daily
    time: "04:00"
  open-pull-requests-limit: 99
  assignees:
  - dadoonet
  labels:
  - update

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
  directory: "/.github/workflows"
  schedule:
    interval: "daily"
    time: "04:00"
  open-pull-requests-limit: 99
  assignees:
  - dadoonet
  labels:
  - update


================================================
FILE: .github/mergify.yml
================================================
pull_request_rules:
  - name: automatic merge on CI success and review
    conditions:
      - check-success=build
      - "#approved-reviews-by>=1"
    actions:
      merge:
        method: merge


================================================
FILE: .github/workflows/maven.yml
================================================
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build and Deploy the master branch

on:
  push:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v5
    - name: Set up JDK 17 and Maven Central Repository
      uses: actions/setup-java@v5
      with:
        java-version: '17'
        distribution: 'adopt'
    - name: Cache Maven packages
      uses: actions/cache@v4
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2
    - name: Build with Maven
      run: mvn --batch-mode --update-snapshots verify

  deploy:
    needs: build
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v5
    - name: Cache Maven packages
      uses: actions/cache@v4
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2
    - name: Set up JDK 14 and Maven Central Repository
      uses: actions/setup-java@v5
      with:
        java-version: '17'
        distribution: 'adopt'
        server-id: sonatype-nexus-snapshots
        server-username: MAVEN_USERNAME
        server-password: MAVEN_PASSWORD
    - name: Deploy with Maven
      run: mvn deploy -DskipTests
      env:
        MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
        MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}


================================================
FILE: .github/workflows/pr.yml
================================================
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build Pull Requests

on: [pull_request]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v5
    - name: Set up JDK 17 and Maven Central Repository
      uses: actions/setup-java@v5
      with:
        java-version: '17'
        distribution: 'adopt'
    - name: Cache Maven packages
      uses: actions/cache@v4
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2
    - name: Build with Maven
      run: mvn --batch-mode --update-snapshots verify


================================================
FILE: .gitignore
================================================
/.project
/.classpath
/.settings
/target
*.iml
*.idea


================================================
FILE: .mvn/jvm.config
================================================
 -Xmx1024m -Xms1024m -Djava.awt.headless=true



================================================
FILE: .mvn/maven.config
================================================
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn


================================================
FILE: LICENSE
================================================

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: NOTICE
================================================
Copyright (c) David Pilato - 2012 

This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).


================================================
FILE: README.md
================================================
# Spring factories for Elasticsearch

**This project is now archived.** 

Please use [Elasticsearch Beyonder](https://github.com/dadoonet/elasticsearch-beyonder/) 
instead. Just inject an Elasticsearch Rest Client bean in your code and use the
`ElasticsearchBeyonder` class to load your indices, templates... Something like:

```java
import org.springframework.context.annotation.Bean;

public class MyApp {
    @Bean
    ElasticsearchClient client;

    public void startBeyonder() {
        ElasticsearchBeyonder.start(client);
    }
}
```

---

Welcome to the Spring factories for [Elasticsearch](https://www.elastic.co/elasticsearch/) project.

The factory provides a [Java Rest Client for Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/)
and automatically create index settings and templates based on what is found in the classpath:

* `/es/_index_lifecycles/` for [index lifecycles policies](#index-lifecycles-policies)
* `/es/INDEXNAME/_settings.json` for [index settings and mappings](#indices) for a given index `INDEXNAME`
* `/es/INDEXNAME/_update_settings.json` to [update existing index settings and mappings](#indices) for a given index `INDEXNAME`
* `/es/_component_templates/` for [component templates](#component-templates)
* `/es/_index_templates/` for [index templates](#index-templates)
* `/es/_pipelines/` for [ingest pipelines](#ingest-pipelines)
* `/es/_aliases.json` for [aliases](#aliases)

## Documentation

* For 8.x elasticsearch versions, you are reading the latest documentation.
* For 7.x elasticsearch versions, look at [es-7.x branch](https://github.com/dadoonet/spring-elasticsearch/tree/es-7.x).
* For 6.x elasticsearch versions, look at [es-6.x branch](https://github.com/dadoonet/spring-elasticsearch/tree/es-6.x).
* For 5.x elasticsearch versions, look at [es-5.x branch](https://github.com/dadoonet/spring-elasticsearch/tree/es-5.x).
* For 2.x elasticsearch versions, look at [es-2.x branch](https://github.com/dadoonet/spring-elasticsearch/tree/es-2.x).
* For 1.x elasticsearch versions, look at [es-1.4 branch](https://github.com/dadoonet/spring-elasticsearch/tree/es-1.4).
* For 0.x elasticsearch versions, look at [0.x branch](https://github.com/dadoonet/spring-elasticsearch/tree/0.x).

| spring-elasticsearch | elasticsearch | Spring | Release date |
|:--------------------:|:-------------:|:------:|:------------:|
|     8.7-SNAPSHOT     |     8.x       | 6.0.7  |              |
|         7.1          |   7.0 - 7.x   | 5.3.15 |  2022-01-13  |
|         7.0          |   7.0 - 7.x   | 5.3.8  |  2021-06-21  |
|         6.7          |   6.7 - 6.x   | 5.1.3  |  2019-04-13  |
|         6.2          |   6.0 - 6.x   | 5.1.3  |  2019-01-08  |
|         6.1          |   6.0 - 6.x   | 5.0.7  |  2018-07-22  |
|         6.0          |   6.0 - 6.x   | 5.0.3  |  2018-02-08  |
|         5.0          |   5.0 - 5.x   | 4.3.10 |  2018-02-04  |
|        2.2.0         |   2.0 - 2.4   | 4.2.3  |  2017-03-09  |
|        2.1.0         |   2.0, 2.1    | 4.2.3  |  2015-11-25  |
|        2.0.0         |      2.0      | 4.1.4  |  2015-10-25  |
|        1.4.2         |     < 2.0     | 4.1.4  |  2015-03-03  |
|        1.4.1         |      1.4      | 4.1.4  |  2015-02-28  |
|        1.4.0         |      1.4      | 4.1.4  |  2015-01-03  |
|        1.3.0         |      1.3      | 4.0.6  |  2014-09-01  |
|        1.0.0         |      1.0      | 3.2.2  |  2014-02-14  |

## Build Status

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/fr.pilato.spring/spring-elasticsearch/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/fr.pilato.spring/spring-elasticsearch/)
[![Build Status](https://github.com/dadoonet/spring-elasticsearch/actions/workflows/maven.yml/badge.svg)](https://github.com/dadoonet/spring-elasticsearch/actions/workflows/maven.yml)

## Release notes

### Changes in 8.7

* Update to Spring 6.0.7
* Update to Java 17 (needed by Spring 6)
* Update to Beyonder 8.6
* Provides now the new official [Java Rest Client for Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/)
* Removed deprecated templates
* Removed deprecated XML support
* As a side effect of a previous removal (TransportClient), async initialization of the client has been removed.
* Deprecated `setProperties(Properties)` method.
* Add a wait for yellow health when creating a new index

### Changes in 7.1

* Update to Beyonder 7.16 which brings in support for index lifecycles. 
You can add your index lifecycles policies in the `_index_lifecycles` dir.

### Major (breaking) changes in 7.0

* The `TransportClient` has been removed.

* As in Elasticsearch 7.x, only one single type is supported, you need to provide the mapping within
  the index settings ( `_settings.json` file). As a consequence:
 * `forceMapping` setting has been replaced by `forceIndex`.
 * `mappings` setting has been replaced by `indices`.
 * `mergeMapping` setting has been removed.

* `forceTemplate` setting has been removed. A template should be always updated.

* `_template` dir has been deprecated by `_templates` dir.

## Getting Started

### Maven dependency

Import spring-elasticsearch in you project `pom.xml` file:

```xml
<dependency>
  <groupId>fr.pilato.spring</groupId>
  <artifactId>spring-elasticsearch</artifactId>
  <version>8.7</version>
</dependency>
```

If you want to set a specific version of the Elasticsearch Java client, add it to your `pom.xml` file:

```xml
<dependencies>
  <dependency>
    <groupId>co.elastic.clients</groupId>
    <artifactId>elasticsearch-java</artifactId>
    <version>${elasticsearch.version}</version>
  </dependency>
  <dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-client</artifactId>
    <version>${elasticsearch.version}</version>
  </dependency>
</dependencies>
```

If you want to try out the most recent SNAPSHOT version [deployed on Sonatype](https://oss.sonatype.org/content/repositories/snapshots/fr/pilato/spring/spring-elasticsearch/):

```xml
<dependency>
  <groupId>fr.pilato.spring</groupId>
  <artifactId>spring-elasticsearch</artifactId>
  <version>8.8-SNAPSHOT</version>
</dependency>
```

Don't forget to add if needed the following repository in your `pom.xml`:

```xml
<repositories>
    <repository>
        <id>oss-snapshots</id>
        <name>Sonatype OSS Snapshots</name>
        <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>
```

If you depend on an elasticsearch SNAPSHOT version, you need to add the following repository to your `pom.xml`:

```xml
<repositories>
    <repository>
        <id>elastic-snapshots</id>
        <name>Elastic Snapshots</name>
        <url>http://snapshots.elastic.co/maven/</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>
```

### Logger

We are using [slf4j](http://www.slf4j.org/) for logging but you have to provide the logging implementation
you want to use and bind it.

For example for this project we are using for tests [log4j2](http://logging.apache.org/log4j/). 
If you want to do so, add to your `pom.xml`:

```xml
<dependencies>
  <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>2.20.0</version>
  </dependency>
  <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j2-impl</artifactId>
      <version>2.20.0</version>
  </dependency>
  <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.20.0</version>
  </dependency>
</dependencies>
```

## Using Java Annotations

Let's say you want to use Spring Java Annotations, here is a typical application you can build.

`pom.xml`:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>fr.pilato.tests</groupId>
    <artifactId>spring-elasticsearch-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>fr.pilato.spring</groupId>
            <artifactId>spring-elasticsearch</artifactId>
            <version>8.7</version>
        </dependency>
    </dependencies>
</project>
```

`App.java`:

```java
package fr.pilato.tests;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class RestApp {

  @Configuration
  public class AppConfig {
    @Bean
    public ElasticsearchClient esClient() {
      ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
      factory.setEsNodes(new String[]{"https://127.0.0.1:9200"});
      factory.setUsername("elastic");
      factory.setPassword("changeme");
      factory.afterPropertiesSet();
      return factory.getObject();
    }
  }

  @Autowired
  private ElasticsearchClient client;

  public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.scan("fr.pilato.tests");
    context.refresh();

    RestApp p = context.getBean(RestApp.class);
    p.run();

    context.close();
  }

  private void run() {
    // Run an advanced request
    client.info();

    // You still have access to the Low Level client
    client.getLowLevel().performRequest(new Request("GET", "/"));
  }
}
```

## Features

The factory provides a [Java Rest Client for Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/)
and automatically create index settings and templates based on what is found in the classpath:

* `/es/INDEXNAME/_settings.json` for [index settings and mappings](#indices) for a given index `INDEXNAME`
* `/es/INDEXNAME/_update_settings.json` to [update existing index settings and mappings](#indices) for a given index `INDEXNAME`
* `/es/_component_templates/` for [component templates](#component-templates)
* `/es/_index_templates/` for [index templates](#index-templates)
* `/es/_pipelines/` for [ingest pipelines](#ingest-pipelines)
* `/es/_aliases.json` for [aliases](#aliases)
* `/es/_index_lifecycles/` for [index lifecycles policies](#index-lifecycles-policies)

### Autoscan

By default, the factory will scan the classpath inside the default `/es` directory.
You can disable the autoscan and then provide manually every name for indices, templates...

```java
ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
factory.setAutoscan(false);
factory.setIndices(new String[]{"twitter"});
```

### Default directory

You can change the default directory from `/es` to something else. The factory will look into this
directory to find the indices and the settings for the indices, templates...

```java
ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
factory.setClasspathRoot("/foo");
```

### Indices

If you add in your classpath a file named `/es/twitter/_settings.json`, it will be automatically applied to define
settings for your `twitter` index.

For example, create the following file `src/main/resources/es/twitter/_settings.json` in your project:

```json
{
  "settings" : {
    "number_of_shards" : 3,
    "number_of_replicas" : 2
  },
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : "yes"}
    }
  }
}
```

If you need to update settings for an existing index, let say `twitter`, add a file named  `/es/twitter/_update_settings.json` 
in your classpath. The factory will detect it and will try to update the settings:

```json
{
  "index" : {
    "number_of_replicas" : 1
  }
}
```

If you want to remove the existing indices every time the factory starts, you can use the `forceIndex` option:

```java
ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
// Be careful: IT WILL REMOVE ALL EXISTING DATA FOR THE MANAGED INDICES.
factory.setForceIndex(true);
```

Be careful: **IT WILL REMOVE ALL EXISTING DATA** FOR THE MANAGED INDICES.


### Component templates

This feature will call the [Component Templates APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-component-template.html).
It's very common to use it with [index templates](#index-templates).

Let say you want to create a component template named `component1`. Just create a file named
`/es/_component_templates/component1.json`:

```json
{
  "template": {
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date"
        }
      }
    }
  }
}
```

Let say you want to create a component template named `component2`. Just create a file named
`/es/_component_templates/component2.json`:

```json
{
  "template": {
    "mappings": {
      "runtime": {
        "day_of_week": {
          "type": "keyword",
          "script": {
            "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
          }
        }
      }
    }
  }
}
```

You can use then the 2 component templates in an index template as shown below.

### Index templates

This feature will call the [Index Templates APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html).
It can be used with [component templates](#component-templates).

Let say you want to create an index template named `template_1`. Just create a file named 
`/es/_index_templates/template_1.json`:

```json
{
  "index_patterns": ["te*", "bar*"],
  "template": {
    "settings": {
      "number_of_shards": 1
    },
    "mappings": {
      "_source": {
        "enabled": true
      },
      "properties": {
        "host_name": {
          "type": "keyword"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z yyyy"
        }
      }
    },
    "aliases": {
      "mydata": { }
    }
  },
  "priority": 500,
  "composed_of": ["component1", "component2"],
  "version": 3,
  "_meta": {
    "description": "my custom"
  }
}
```

Note that this index template is using the 2 component templates that have been defined in the previous section.

### Aliases

An alias is helpful to define or remove an alias to a given index. You could also use an [index templates](#index-templates)
to do that automatically when at index creation time, but you can also define a file `/es/_aliases.json`:

```json
{
  "actions" : [
    { "remove": { "index": "test_1", "alias": "test" } },
    { "add":  { "index": "test_2", "alias": "test" } }
  ]
}
```

When the factory starts, it will automatically send the content to the [Aliases API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html)
and move the alias `test` from index `test_1` to index `test_2`.

### Ingest Pipelines

This feature will call the [Ingest Pipelines APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)

Let say you want to create an ingest pipeline named `pipeline1`. Just create a file named
`/es/_pipeline/pipeline1.json`:

```json
{
  "description": "My optional pipeline description",
  "processors": [
    {
      "set": {
        "description": "My optional processor description",
        "field": "my-long-field",
        "value": 10
      }
    },
    {
      "set": {
        "description": "Set 'my-boolean-field' to true",
        "field": "my-boolean-field",
        "value": true
      }
    },
    {
      "lowercase": {
        "field": "my-keyword-field"
      }
    }
  ]
}
```

### Index Lifecycles Policies

This feature will call the [Index Lifecycle APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html).

Let say you want to create a policy named `policy1`. Just create a file named
`/es/_index_lifecycles/policy1.json`:

```json
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "10d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}
```

It will be automatically loaded into elasticsearch when you start the factory.
If you want to apply this policy to your index, you can define the following settings for the index in
`/es/twitter/_settings.json`:

```json
{
	"settings" : {
		"index.lifecycle.name": "policy1"
	}
}
```

### SSL certificates

If you need to specify your own SSL certificates (self-signed certificates), you can use the `setSSLContext(SSLContext)`
method to do this.
You can refer to the Elasticsearch [Low Level client documentation](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/_encrypted_communication.html)
to see some examples. Once you have created a SSLContext, you can use it in the factory:

```java
Path trustStorePath = Paths.get("/path/to/truststore.p12");
KeyStore truststore = KeyStore.getInstance("pkcs12");
try (InputStream is = Files.newInputStream(trustStorePath)) {
    truststore.load(is, keyStorePass.toCharArray());
}
SSLContextBuilder sslBuilder = SSLContexts.custom().loadTrustMaterial(truststore, null);
final SSLContext sslContext = sslBuilder.build();

ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
factory.setSslContext(sslContext);
```

# Thanks

Special thanks to

- [Nicolas Huray](https://github.com/nhuray) for his contribution about
[templates](https://github.com/dadoonet/spring-elasticsearch/pull/4)
- [Nicolas Labrot](https://github.com/nithril) for his contribution about
[async](https://github.com/dadoonet/spring-elasticsearch/pull/30)

# Running tests

If you want to run tests (integration tests) from your IDE, you need to start first an elasticsearch instance.
Tests are expecting a node running at `https://localhost:9200` with the user `elastic` and `changeme` as the password.

To run the tests using Maven (on the CLI), just run:

```sh
mvn clean install
```

You can change the target to run the tests. For example, if you want to run the tests against an elastic cloud instance:

```shell
mvn clean install -Dtests.cluster=https://ID.es.ZONE.PROVIDER.cloud.es.io -Dtests.cluster.user=myuser -Dtests.cluster.pass=YOURPASSWORD
```

# Release guide

To release the project you need to run the release plugin with the `release` profile as you need to sign the artifacts:

```sh
mvn release:prepare
git push --tags
git push
mvn release:perform -Prelease
```

If you need to skip the tests, run:

```sh
mvn release:perform -Prelease -Darguments="-DskipTests"
```

If everything is ok in https://s01.oss.sonatype.org/#stagingRepositories, you can perform the release with:

```sh
mvn nexus-staging:release
mvn nexus-staging:drop
```

To announce the release, run:

```sh
cd target/checkout
# Run the following command if you want to check the announcement email
mvn changes:announcement-generate
cat target/announcement/announcement.vm

# Announce the release (change your smtp username and password)
mvn changes:announcement-mail -Dchanges.username='YourSmtpUserName' -Dchanges.password='YourSmtpUserPassword'
```

# License

This software is licensed under the Apache 2 license, quoted below.

	Copyright 2011-2023 David Pilato
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not
	use this file except in compliance with the License. You may obtain a copy of
	the License at
	
	    http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
	License for the specific language governing permissions and limitations under
	the License.


================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>fr.pilato.spring</groupId>
    <artifactId>spring-elasticsearch</artifactId>
    <packaging>jar</packaging>
    <name>spring-elasticsearch</name>
    <version>8.7-SNAPSHOT</version>
    <url>https://github.com/dadoonet/spring-elasticsearch</url>
    <description>Spring factories for Elasticsearch</description>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.compiler.version>17</java.compiler.version>

        <spring.version>6.2.11</spring.version>
        <elasticsearch.version>8.11.0</elasticsearch.version>
        <beyonder.version>8.6-SNAPSHOT</beyonder.version>
        <slf4j.version>2.0.17</slf4j.version>
        <log4j.version>2.25.1</log4j.version>
        <commons.io.version>2.20.0</commons.io.version>
        <jackson.version>2.20.0</jackson.version>
        <junit.version>5.13.4</junit.version>

        <skipTests>false</skipTests>
        <skip.unit.tests>${skipTests}</skip.unit.tests>
        <skip.integration.tests>${skipTests}</skip.integration.tests>
        <tests.cluster.username>elastic</tests.cluster.username>
        <tests.cluster.password>changeme</tests.cluster.password>
        <tests.cluster.credentials>${tests.cluster.username}:${tests.cluster.password}</tests.cluster.credentials>

        <!-- For integration tests using Docker or external cluster -->
        <integ.elasticsearch.image>docker.elastic.co/elasticsearch/elasticsearch</integ.elasticsearch.image>
        <integ.elasticsearch.version>${elasticsearch.version}</integ.elasticsearch.version>
        <tests.cluster.rest.port>9200</tests.cluster.rest.port>
        <tests.cluster.transport.port>9300</tests.cluster.transport.port>

        <!-- Smtp Settings for announcements -->
        <changes.smtpHost>smtp.ionos.fr</changes.smtpHost>
        <changes.smtpPort implementation="java.lang.Integer">465</changes.smtpPort>
    </properties>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <developers>
        <developer>
            <id>dadoonet</id>
            <name>David Pilato</name>
            <email>david@pilato.fr</email>
            <url>http://david.pilato.fr/</url>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <id>nhuray</id>
            <name>Nicolas Huray</name>
            <url>https://github.com/nhuray/</url>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <id>nlabrot</id>
            <name>Nicolas Labrot</name>
            <url>https://github.com/nithril‎/</url>
            <timezone>Europe/Paris</timezone>
        </developer>
    </developers>

    <scm>
        <url>scm:git:git@github.com:dadoonet/spring-elasticsearch.git</url>
        <connection>scm:git:git@github.com:dadoonet/spring-elasticsearch.git</connection>
        <developerConnection>scm:git:git@github.com:dadoonet/spring-elasticsearch.git</developerConnection>
      <tag>HEAD</tag>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/dadoonet/spring-elasticsearch/issues/</url>
    </issueManagement>

    <repositories>
        <repository>
            <id>elastic-download-service</id>
            <name>Elastic Download Service</name>
            <url>https://artifacts.elastic.co/maven/</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

        <repository>
            <id>elastic-snapshots</id>
            <name>Elastic Snapshots</name>
            <url>https://snapshots.elastic.co/maven/</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>

        <repository>
            <id>oss-snapshots</id>
            <name>Sonatype OSS Snapshots</name>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Logging dependencies -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <!-- LOG4J2 implementation is optional -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
            <version>${log4j.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
            <optional>true</optional>
        </dependency>

        <!-- Elasticsearch -->
        <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.pilato.elasticsearch</groupId>
            <artifactId>elasticsearch-beyonder</artifactId>
            <version>${beyonder.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons.io.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>3.5.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.14.1</version>
                <configuration>
                    <source>${java.compiler.version}</source>
                    <target>${java.compiler.version}</target>
                    <encoding>UTF-8</encoding>
                    <optimize>true</optimize>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <compilerArgument>-Xlint:all,-serial,-path,-rawtypes,-unchecked</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <rules>
                        <requireJavaVersion>
                            <version>${java.compiler.version}</version>
                        </requireJavaVersion>
                    </rules>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.13</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>sonatype-nexus-staging</serverId>
                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>false</autoReleaseAfterClose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <version>2.1.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-changes-plugin</artifactId>
                <version>2.12.1</version>
                <configuration>
                    <sslMode>true</sslMode>
                    <fromDeveloperId>dadoonet</fromDeveloperId>
                    <toAddresses>
                        <toAddress implementation="java.lang.String">discuss+community-plugins@elastic.co</toAddress>
                    </toAddresses>
                    <issueManagementSystems>
                        <issueManagementSystem>GitHub</issueManagementSystem>
                    </issueManagementSystems>
                    <issueTypes>
                        <add>new,doc</add>
                        <fix>bug</fix>
                        <update>update</update>
                        <remove>remove</remove>
                    </issueTypes>
                    <onlyCurrentVersion>true</onlyCurrentVersion>
                    <urlDownload>
                        https://repo1.maven.org/maven2/fr/pilato/spring/spring-elasticsearch/${project.version}/
                    </urlDownload>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <pushChanges>false</pushChanges>
                </configuration>
            </plugin>
            <!-- For IT using Docker -->
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.46.0</version>
                <configuration>
                    <images>
                        <image>
                            <alias>spring-elasticsearch</alias>
                            <name>dadoonet/spring-elasticsearch:${project.version}</name>
                            <build>
                                <from>${integ.elasticsearch.image}:${integ.elasticsearch.version}</from>
                                <env>
                                    <discovery.type>single-node</discovery.type>
                                    <ELASTIC_PASSWORD>${tests.cluster.password}</ELASTIC_PASSWORD>
                                </env>
                            </build>
                            <run>
                                <ports>
                                    <port>tests.cluster.rest.port:9200</port>
                                </ports>
                                <wait>
                                    <http>
                                        <url>https://localhost:${tests.cluster.rest.port}/</url>
                                        <status>200..499</status>
                                        <allowAllHosts>true</allowAllHosts>
                                    </http>
                                    <time>60000</time>
                                </wait>
                            </run>
                        </image>
                    </images>
                    <skip>${skip.integration.tests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>start-elasticsearch</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>build</goal>
                            <goal>stop</goal>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-elasticsearch</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.4</version>
                <configuration>
                    <!-- Skips unit tests if the value of skip.unit.tests property is true -->
                    <skipTests>${skip.unit.tests}</skipTests>
                    <!-- Excludes integration tests when unit tests are run -->
                    <excludes>
                        <exclude>**/it/**/*Test.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.5.4</version>
                <dependencies>
                    <!-- Workaround for https://issues.apache.org/jira/browse/SUREFIRE-1732
                     TODO remove with next version of failsafe plugin
                     -->
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-api</artifactId>
                        <version>3.5.4</version>
                    </dependency>
                </dependencies>
                <executions>
                    <!--
                        Invokes both the integration-test and the verify goals of the
                        Failsafe Maven plugin
                    -->
                    <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <!--
                                Skips integration tests if the value of skip.integration.tests
                                property is true
                            -->
                            <skipTests>${skip.integration.tests}</skipTests>
                            <!-- Excludes integration tests when unit tests are run -->
                            <includes>
                                <include>**/it/**/*Test.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.12.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>


================================================
FILE: src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchClientFactoryBean.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.HealthStatus;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import fr.pilato.elasticsearch.tools.util.ResourceList;
import fr.pilato.elasticsearch.tools.util.SettingsFinder;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;

import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Properties;

import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchAliasUpdater.manageAliases;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchAliasUpdater.manageAliasesWithJsonInElasticsearch;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchComponentTemplateUpdater.createComponentTemplate;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchIndexLifecycleUpdater.createIndexLifecycle;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchIndexTemplateUpdater.createIndexTemplate;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchIndexUpdater.createIndex;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchIndexUpdater.updateSettings;
import static fr.pilato.elasticsearch.tools.updaters.ElasticsearchPipelineUpdater.createPipeline;
import static fr.pilato.elasticsearch.tools.util.ResourceList.findIndexNames;

/**
 * An abstract {@link FactoryBean} used to create an Elasticsearch
 * {@link ElasticsearchClient}.
 * <p>
 * The lifecycle of the underlying {@link ElasticsearchClient} instance is tied to the
 * lifecycle of the bean via the {@link #destroy()} method which calls
 * {@link RestClient#close()}
 * </p>
 * <p>
 * If not using the default https://localhost:9200, you need to define the nodes you want to communicate with
 * and probably the credentials.
 * </p>
 * <p>Example :</p>
 * <pre>
 * {@code
 * @Configuration
 * public class AppConfig {
 *    @Bean
 *    public ElasticsearchClient esClient() throws Exception {
 * 		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
 * 	    factory.setEsNodes(List.of(HttpHost.create("https://localhost:9200")));
 * 		factory.setPassword("changeme");
 * 		factory.afterPropertiesSet();
 * 		return factory.getObject();
 *    }
 *  }
 * }
 * </pre>
 * <p>
 * The factory is meant to be used with some classpath files which are automatically
 * loaded from {@code /es} directory to define your:
 * <ul>
 *   <li>component templates: {@code /es/_component_templates/*.json}
 *   <li>index templates: {@code /es/_index_templates/*.json}
 *   <li>indices: {@code /es/INDEXNAME/_settings.json}
 *   <li>aliases: {@code /es/_aliases.json}
 *   <li>index lifecycles policies: {@code /es/_index_lifecycles/*.json}
 *   <li>ingest pipelines: {@code /es/_pipelines/*.json}
 * </ul>
 *
 * <p>You can force the manual creation of the above components but this is
 * not the goal of this factory. So it should be used only for some specific use cases:
 * </p>
 * <p>
 * Example :
 * </p>
 * <pre>
 * {@code
 * @Configuration
 * public class AppConfig {
 *    @Bean
 *    public ElasticsearchClient esClient() throws Exception {
 *      ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
 * 	    // Create two indices twitter and rss
 * 	    factory.setIndices(new String[]{ "twitter", "rss" });
 * 	    // Create an alias alltheworld on top of twitter and rss indices
 * 	    factory.setAliases(new String[]{ "alltheworld:twitter", "alltheworld:rss" });
 * 	    // Remove all the existing declared indices (twitter and rss). VERY DANGEROUS SETTING!
 * 	    factory.setForceIndex(true);
 * 	    // If setForceIndex is not set, we try to merge existing index settings
 * 	    // with the provided ones
 * 	    factory.setMergeSettings(true);
 * 	    // Disable automatic scanning of the classpath.
 * 	    factory.setAutoscan(false);
 *      factory.afterPropertiesSet();
 *      return factory.getObject();
 *    }
 *  }
 * }
 * </pre>
 * By default, indexes are created with their default Elasticsearch settings. You can specify
 * your own settings for your index by putting a /es/indexname/_settings.json in your classpath.
 * <br>
 * So if you create a file named /es/twitter/_settings.json in your src/main/resources folder (for maven lovers),
 * it will be used by the factory to create the twitter index.
 * <pre>
 {
  "settings" : {
   "number_of_shards" : 3,
   "number_of_replicas" : 2
  },
  "mappings" : {
   "properties" : {
    "message" : {"type" : "text"}
   }
  }
 }
 * </pre>
 *
 * By convention, the factory will create all settings found under the /es classpath.<br>
 * You can disable convention and use configuration by setting autoscan to false.
 *
 * @see ElasticsearchClient
 * @author David Pilato
 */
public class ElasticsearchClientFactoryBean
        implements FactoryBean<ElasticsearchClient>, InitializingBean, DisposableBean {

    private static final Logger logger = LoggerFactory.getLogger(ElasticsearchClientFactoryBean.class);

    /**
     * Define the username:password to use.
     * @deprecated Now deprecated with username and password settings.
     * @see ElasticsearchClientFactoryBean#setUsername(String)
     * @see ElasticsearchClientFactoryBean#setPassword(String)
     */
    @Deprecated
    public final static String XPACK_USER = "xpack.security.user";

    private RestClient lowLevelClient;

    private boolean forceIndex;

    private boolean mergeSettings = true;

    private boolean autoscan = true;

    private String username;
    private String password;

    // TODO add support for keys

    @Deprecated
    private String[] indices;

    @Deprecated
    private String[] aliases;

    @Deprecated
    private String[] componentTemplates;

    @Deprecated
    private String[] indexTemplates;

    @Deprecated
    private String[] pipelines;

    @Deprecated
    private String[] lifecycles;

    private String classpathRoot = "es";

    private Collection<HttpHost> esNodes = List.of(HttpHost.create("https://localhost:9200"));

    private ElasticsearchClient client;

    private SSLContext sslContext;

    public RestClient getLowLevelClient() {
        return lowLevelClient;
    }

    /**
     * Elasticsearch properties
     * @param properties the properties
     * @deprecated it was only used to set xpack.security.user. Please use now {@link #setUsername(String)}
     * and {@link #setPassword(String)}.
     */
    @Deprecated
    public void setProperties(Properties properties) {
        String securedUser = properties.getProperty(XPACK_USER, null);
        if (securedUser != null) {
            logger.warn("Usage of xpack.security.user property has been deprecated. " +
                    "You should now use username and password factory settings.");

            // We split the username and the password
            String[] split = securedUser.split(":");
            if (split.length < 2) {
                throw new IllegalArgumentException(XPACK_USER + " must have the form username:password");
            }
            username = split[0];
            password = split[1];
        }
    }

    /**
     * Set to true if you want to force reinit the indices. This will remove all existing indices managed by the factory.
     * @param forceIndex true if you want to force reinit the indices
     */
    public void setForceIndex(boolean forceIndex) {
        this.forceIndex = forceIndex;
    }

    /**
     * Set to true if you want to try to merge index settings
     * @param mergeSettings true if you want to try to merge index settings
     */
    public void setMergeSettings(boolean mergeSettings) {
        this.mergeSettings = mergeSettings;
    }

    /**
     * Set to false if you want to use configuration instead of convention.
     * @param autoscan false if you want to use configuration instead of convention.
     * @deprecated you must use automatic discovery
     */
    @Deprecated
    public void setAutoscan(boolean autoscan) {
        this.autoscan = autoscan;
    }

    /**
     * Define the Elasticsearch username. Defaults to "elastic".
     * @param username Elasticsearch username.
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Define the Elasticsearch password. Must be provided.
     * @param password Elasticsearch password.
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Define indices you want to manage with this factory
     * in case you are not using automatic discovery (see {@link #setAutoscan(boolean)})
     * @param indices Array of index names
     * @deprecated you must use automatic discovery (see {@link #setAutoscan(boolean)})
     */
    @Deprecated
    public void setIndices(String[] indices) {
        this.indices = indices;
    }

    /**
     * Define aliases you want to manage with this factory
     * in case you are not using automatic discovery (see {@link #setAutoscan(boolean)})
     * @param aliases alias array of aliasname:indexname
     * @deprecated you must use automatic discovery (see {@link #setAutoscan(boolean)})
     */
    @Deprecated
    public void setAliases(String[] aliases) {
        this.aliases = aliases;
    }

    /**
     * Define the index templates you want to manage with this factory
     * in case you are not using automatic discovery (see {@link #setAutoscan(boolean)})
     * @param indexTemplates list of index templates
     * @deprecated you must use automatic discovery (see {@link #setAutoscan(boolean)})
     */
    @Deprecated
    public void setIndexTemplates(String[] indexTemplates) {
        this.indexTemplates = indexTemplates;
    }

    /**
     * Define component templates you want to manage with this factory
     * in case you are not using automatic discovery (see {@link #setAutoscan(boolean)})
     * @param componentTemplates list of component templates
     * @deprecated you must use automatic discovery (see {@link #setAutoscan(boolean)})
     */
    @Deprecated
    public void setComponentTemplates(String[] componentTemplates) {
        this.componentTemplates = componentTemplates;
    }

    /**
     * Define the pipelines you want to manage with this factory
     * in case you are not using automatic discovery (see {@link #setAutoscan(boolean)})
     * @param pipelines list of pipelines
     * @deprecated you must use automatic discovery (see {@link #setAutoscan(boolean)})
     */
    @Deprecated
    public void setPipelines(String[] pipelines) {
        this.pipelines = pipelines;
    }

    /**
     * Classpath root for index and mapping files (default : /es)
     * <p>Example :</p>
     * <pre>
     * {@code
     * factory.setClasspathRoot("/es");
     * }
     * </pre>
     * That means that the factory will look in es folder to find index settings.
     * <br>So if you want to define settings or mappings for the twitter index, you
     * should put a _settings.json file under /es/twitter/ folder.
     * @param classpathRoot Classpath root for index and mapping files
     */
    public void setClasspathRoot(String classpathRoot) {
        // For compatibility reasons, we need to convert "/classpathroot" to "classpathroot"
        if (classpathRoot.startsWith("/")) {
            this.classpathRoot = classpathRoot.substring(1);
        } else {

            this.classpathRoot = classpathRoot;
        }
    }

    /**
     * Define ES nodes to communicate with.
     * Defaults to [ "https://localhost:9200" ].
     * @param esNodes A collection of nodes
     */
    public void setEsNodes(Collection<HttpHost> esNodes) {
        this.esNodes = esNodes;
    }

    /**
     * Define ES nodes to communicate with.
     * <br>use : protocol://hostname:port form
     * @param esNodes An array of nodes hostname:port
     * @deprecated #setEsNodes(HttpHost[])
     */
    @Deprecated
    public void setEsNodes(String[] esNodes) {
        Collection<HttpHost> hosts = new ArrayList<>(esNodes.length);
        for (String esNode : esNodes) {
            hosts.add(HttpHost.create(esNode));
        }

        this.esNodes = hosts;
    }

    /**
     * Define the SSLContext to use if any
     * @param sslContext    SSLContext
     * @see SSLUtils#yesSSLContext() for test purposes
     * @see SSLUtils#createSslContextFromCa(String) when you want to pass the Elasticsearch self-signed certificate
     */
    public void setSslContext(SSLContext sslContext) {
        this.sslContext = sslContext;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("Starting Elasticsearch Low Level client");
        lowLevelClient = buildElasticsearchLowLevelClient();

        logger.info("Starting Elasticsearch client");
        // Create the transport with a Jackson mapper
        ElasticsearchTransport transport = new RestClientTransport(lowLevelClient, new JacksonJsonpMapper());
        // And create the API client
        client = new ElasticsearchClient(transport);

        // Automagically initialize the cluster/indices
        initLifecycles();
        initPipelines();
        initTemplates();
        initSettings();
        initAliases();
    }

    @Override
    public void destroy() {
        try {
            logger.info("Closing Elasticsearch Low Level client");
            if (lowLevelClient != null) {
                lowLevelClient.close();
            }
        } catch (final Exception e) {
            logger.error("Error closing Elasticsearch Low Level client: ", e);
        }
    }

    @Override
    public ElasticsearchClient getObject() {
        return client;
    }

    @Override
    public Class<ElasticsearchClient> getObjectType() {
        return ElasticsearchClient.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    /**
     * We use convention over configuration : see <a href="https://github.com/dadoonet/spring-elasticsearch/issues/3">...</a>
     */
    static String[] computeIndexNames(boolean autoscan, String[] resources, String classpathRoot) {
        if (!autoscan) {
            logger.debug("Automatic discovery is disabled. Only static resources are used: {}", (Object) resources);
            return resources;
        }
        if (resources != null && resources.length > 0) {
            logger.debug("Resources are manually provided so we won't do any automatic discovery.");
            return resources;
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Automatic discovery is activated. Looking for definition files in classpath under [{}].",
                    classpathRoot);
        }

        try {
            // Let's scan our resources
            return findIndexNames(classpathRoot).toArray(new String[0]);
        } catch (IOException |URISyntaxException e) {
            logger.debug("Automatic discovery does not succeed for finding json files in classpath under " + classpathRoot + ".");
            logger.trace("", e);
            return null;
        }
    }

    static String[] discoverFromClasspath(boolean autoscan, String[] resources, String classpathRoot, String subdir) {
        if (!autoscan) {
            logger.debug("Automatic discovery is disabled. Only static resources are used: {}", (Object) resources);
            return resources;
        }
        if (resources != null && resources.length > 0) {
            logger.debug("Resources are manually provided so we won't do any automatic discovery.");
            return resources;
        }

        logger.debug("Automatic discovery is activated. Looking for resource files in classpath under [{}/{}].",
                classpathRoot, subdir);
        ArrayList<String> autoResources = new ArrayList<>();
        try {
            // Let's scan our resources
            List<String> scannedResources = ResourceList.getResourceNames(classpathRoot, subdir);
            autoResources.addAll(scannedResources);

            return autoResources.toArray(new String[0]);
        } catch (IOException|URISyntaxException e) {
            logger.debug("Automatic discovery does not succeed for finding json files in classpath under [{}/{}].", classpathRoot, subdir);
            logger.trace("", e);
            return resources;
        }
    }

    /**
     * Init index settings if needed.
     * <p>Note that you can force to reinit the index using {@link #setForceIndex(boolean)}
     */
    private void initSettings() throws Exception {
        logger.debug("Initializing indices");
        String[] indices = computeIndexNames(autoscan, this.indices, classpathRoot);
        // We extract indexes and mappings to manage from mappings definition
        if (indices != null) {
            // Let's initialize indexes and mappings if needed
            for (String index : indices) {
                logger.debug("Initializing index {}", index);
                createIndex(lowLevelClient, classpathRoot, index, forceIndex);
                if (mergeSettings) {
                    updateSettings(lowLevelClient, classpathRoot, index);
                }
            }

            // Let's wait until the index is properly ready to be used
            client.cluster().health(hrb -> hrb.index(Arrays.stream(indices).toList()).waitForStatus(HealthStatus.Yellow));
        }
    }

    /**
     * It creates or updates:
     * <ul>
     *     <li>component templates</li>
     *     <li>index templates</li>
     * </ul>
     */
    private void initTemplates() throws Exception {
        logger.debug("Initializing component templates");
        String[] componentTemplates = discoverFromClasspath(autoscan, this.componentTemplates, classpathRoot, SettingsFinder.Defaults.ComponentTemplatesDir);
        if (componentTemplates != null) {
            for (String componentTemplate : componentTemplates) {
                logger.debug("Initializing component template {}", componentTemplate);
                Assert.hasText(componentTemplate, "Can not read component template in ["
                        + componentTemplate
                        + "]. Check that component template is not empty.");
                createComponentTemplate(lowLevelClient, classpathRoot, componentTemplate);
            }
        }
        logger.debug("Initializing index templates");
        String[] indexTemplates = discoverFromClasspath(autoscan, this.indexTemplates, classpathRoot, SettingsFinder.Defaults.IndexTemplatesDir);
        if (indexTemplates != null) {
            for (String indexTemplate : indexTemplates) {
                logger.debug("Initializing index template {}", indexTemplate);
                Assert.hasText(indexTemplate, "Can not read component template in ["
                        + indexTemplate
                        + "]. Check that component template is not empty.");
                createIndexTemplate(lowLevelClient, classpathRoot, indexTemplate);
            }
        }
    }

    /**
     * It creates or updates the index pipelines
     */
    private void initPipelines() throws Exception {
        logger.debug("Initializing ingest pipelines");
        String[] pipelines = discoverFromClasspath(autoscan, this.pipelines, classpathRoot, SettingsFinder.Defaults.PipelinesDir);
        if (pipelines != null) {
            for (String pipeline : pipelines) {
                logger.debug("Initializing pipeline {}", pipeline);
                Assert.hasText(pipeline, "Can not read pipeline in ["
                        + pipeline
                        + "]. Check that pipeline is not empty.");
                createPipeline(lowLevelClient, classpathRoot, pipeline);
            }
        }
    }

    /**
     * It creates or updates the index lifecycles
     */
    private void initLifecycles() throws Exception {
        logger.debug("Initializing lifecycle policies");
        String [] lifecycles = discoverFromClasspath(autoscan, this.lifecycles, classpathRoot, SettingsFinder.Defaults.IndexLifecyclesDir);
        if (lifecycles != null) {
            for (String lifecycle : lifecycles) {
                logger.debug("Initializing lifecycle {}", lifecycle);
                Assert.hasText(lifecycle, "Can not read lifecycle in ["
                        + lifecycle
                        + "]. Check that lifecycle is not empty.");
                createIndexLifecycle(lowLevelClient, classpathRoot, lifecycle);
            }
        }
    }

    /**
     * Init aliases if needed.
     */
    private void initAliases() throws Exception {
        logger.debug("Initializing aliases");

        if (!autoscan) {
            logger.debug("Automatic discovery is disabled. Only static resources are used: {}", (Object) aliases);
        } else {
            logger.debug("Automatic discovery is activated. Looking for aliases in classpath under [{}/{}{}].",
                    classpathRoot, SettingsFinder.Defaults.AliasesFile, SettingsFinder.Defaults.JsonFileExtension);
        }

        if (aliases != null && aliases.length > 0) {
            logger.debug("Resources are manually provided so we won't do any automatic discovery.");
            String request = "{\"actions\":[";
            boolean first = true;
			for (String aliasIndex : aliases) {
			    if (!first) {
                    request += ",";
                }
			    first = false;
                Tuple<String, String> aliasIndexSplitted = computeAlias(aliasIndex);
                logger.debug("add alias {} on index {}", aliasIndexSplitted.v2(), aliasIndexSplitted.v1());
                request += "{\"add\":{\"index\":\"" + aliasIndexSplitted.v1() +"\",\"alias\":\"" + aliasIndexSplitted.v2() +"\"}}";
			}
            request += "]}";
            manageAliasesWithJsonInElasticsearch(lowLevelClient, request);
        } else {
		    manageAliases(lowLevelClient, classpathRoot);
        }
    }

    static Tuple<String, String> computeAlias(String aliasIndex) {
        String[] aliasIndexSplitted = aliasIndex.split(":");
        String alias = aliasIndexSplitted[0];
        String index = aliasIndexSplitted[1];

        if (index == null) throw new IllegalArgumentException("Can not read index in [" + aliasIndex +
                "]. Check that aliases contains only aliasname:indexname elements.");
        if (alias == null) throw new IllegalArgumentException("Can not read mapping in [" + aliasIndex +
                "]. Check that aliases contains only aliasname:indexname elements.");

        return new Tuple<>(index, alias);
    }

	private RestClient buildElasticsearchLowLevelClient() {
        RestClientBuilder rcb = RestClient.builder(esNodes.toArray(new HttpHost[]{}));

        // We need to check if we have a user security property
        if (username == null || password == null) {
            throw new IllegalArgumentException("From version 8, you MUST define a user and a password to access Elasticsearch.");
        }

        final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
        credentialsProvider.setCredentials(AuthScope.ANY,
                new UsernamePasswordCredentials(username, password));

        rcb.setHttpClientConfigCallback(hcb -> {
            hcb.setDefaultCredentialsProvider(credentialsProvider);
            if (sslContext != null) {
                hcb.setSSLContext(sslContext);
            }
            return hcb;
        });

        return rcb.build();
	}
}


================================================
FILE: src/main/java/fr/pilato/spring/elasticsearch/SSLUtils.java
================================================
/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch;

import org.apache.commons.io.IOUtils;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;

public class SSLUtils {
    private static final Logger logger = LoggerFactory.getLogger(SSLUtils.class);
    private static SSLContext yesCtx = null;
    private static SSLContext checkCertificatesSSLContext = null;

    /**
     * Returns an SSLContext that will accept any server certificate.
     * Use with great care and in limited situations, as it allows MITM attacks.
     */
    public static SSLContext yesSSLContext() {
        logger.warn("You disabled checking the https certificate. This could lead to " +
                "'Man in the middle' attacks. This setting is only intended for tests.");

        if (yesCtx == null) {
            X509TrustManager yesTm = new X509TrustManager() {
                @Override
                public void checkClientTrusted(X509Certificate[] certs, String authType) {
                    // Accept anything
                }

                @Override
                public void  checkServerTrusted(X509Certificate[] certs, String authType) {
                    // Accept anything
                }

                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    return new X509Certificate[0];
                }
            };

            try {
                SSLContext ctx = SSLContext.getInstance("SSL");
                ctx.init(null, new X509TrustManager[] { yesTm }, null);
                yesCtx = ctx;
            } catch (Exception e) {
                // An exception here means SSL is not supported, which is unlikely
                throw new RuntimeException(e);
            }
        }

        return yesCtx;
    }

    /**
     *
     * @param trustStore
     * @param keyStoreType  pkcs12
     * @return
     */
    public static SSLContext checkCertificatesSSLContext(String trustStore, String keyStoreType, String keyStorePass) {
        if (checkCertificatesSSLContext == null) {
            try {
                Path trustStorePath = Paths.get(trustStore);
                KeyStore truststore = KeyStore.getInstance(keyStoreType);
                try (InputStream is = Files.newInputStream(trustStorePath)) {
                    truststore.load(is, keyStorePass.toCharArray());
                }
                SSLContextBuilder sslBuilder = SSLContexts.custom().loadTrustMaterial(truststore, null);
                checkCertificatesSSLContext = sslBuilder.build();
            } catch (IOException | CertificateException | NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
                logger.error("Can not load the SSLContext for {}, {}", trustStore, keyStoreType);
            }
        }
        return checkCertificatesSSLContext;
    }

    /**
     * A SSL context based on the self signed CA, so that using this SSL Context allows to connect to the Elasticsearch service
     * @return a customized SSL Context
     */
    public SSLContext createSslContextFromCa(String certPath) {
        try {
            byte[] bytes = IOUtils.resourceToByteArray(certPath);
            CertificateFactory factory = CertificateFactory.getInstance("X.509");
            Certificate trustedCa = factory.generateCertificate(new ByteArrayInputStream(bytes));
            KeyStore trustStore = KeyStore.getInstance("pkcs12");
            trustStore.load(null, null);
            trustStore.setCertificateEntry("ca", trustedCa);

            final SSLContext sslContext = SSLContext.getInstance("TLSv1.3");
            TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmfactory.init(trustStore);
            sslContext.init(null, tmfactory.getTrustManagers(), null);
            return sslContext;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}


================================================
FILE: src/main/java/fr/pilato/spring/elasticsearch/Tuple.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch;

public class Tuple<V1, V2> {

    public static <V1, V2> Tuple<V1, V2> tuple(V1 v1, V2 v2) {
        return new Tuple<>(v1, v2);
    }

    private final V1 v1;
    private final V2 v2;

    public Tuple(V1 v1, V2 v2) {
        this.v1 = v1;
        this.v2 = v2;
    }

    public V1 v1() {
        return v1;
    }

    public V2 v2() {
        return v2;
    }

    @Override
    public String toString() {
        return "Tuple [v1=" + v1 + ", v2=" + v2 + "]";
    }
}


================================================
FILE: src/main/resources/org/apache/maven/plugin/announcement/announcement.vm
================================================
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements.  See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership.  The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License.  You may obtain a copy of the License at
##
##  http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied.  See the License for the
## specific language governing permissions and limitations
## under the License.
The ${developmentTeam} is pleased to announce the **${finalName}** release!

# ${introduction}

<h2>Usage</h2>

Add this library to you project:

```
<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>${project.artifactId}</artifactId>
    <version>${project.version}</version>
</dependency>
```

#if ($release.getActions().size() == 0)
No changes defined in this version.
#else

#if ($release.getActions('add').size() !=0)
<h2>New features</h2>

#foreach($actionItem in $release.getActions('add'))
#set($action=$actionItem.getAction())
#if ($actionItem.getIssue())
#set($issue=$actionItem.getIssue())
#else
#set($issue="")
#end
#if ($actionItem.getDueTo())
#set($dueto=$actionItem.getDueTo())
#else
#set($dueto="")
#end
* [#$issue](https://github.com/dadoonet/spring-elasticsearch/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end

#set($issue="")
#set($dueto="")
#end
#end

#if ($release.getActions('fix').size() !=0)
<h2>Fixed Bugs</h2>

#foreach($actionItem in $release.getActions('fix'))
#set($action=$actionItem.getAction())
#if ($actionItem.getIssue())
#set($issue=$actionItem.getIssue())
#else
#set($issue="")
#end
#if ($actionItem.getDueTo())
#set($dueto=$actionItem.getDueTo())
#else
#set($dueto="")
#end
* [#$issue](https://github.com/dadoonet/spring-elasticsearch/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end

#set($issue="")
#set($dueto="")
#end
#end

#if ($release.getActions('update').size() !=0)
<h2>Changes</h2>

#foreach($actionItem in $release.getActions('update'))
#set($action=$actionItem.getAction())
#if ($actionItem.getIssue())
#set($issue=$actionItem.getIssue())
#else
#set($issue="")
#end
#if ($actionItem.getDueTo())
#set($dueto=$actionItem.getDueTo())
#else
#set($dueto="")
#end
* [#$issue](https://github.com/dadoonet/spring-elasticsearch/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end

#set($issue="")
#set($dueto="")
#end
#end

#if ($release.getActions('remove').size() !=0)
<h2>Removed</h2>

#foreach($actionItem in $release.getActions('remove'))
#set($action=$actionItem.getAction())
#if ($actionItem.getIssue())
#set($issue=$actionItem.getIssue())
#else
#set($issue="")
#end
#if ($actionItem.getDueTo())
#set($dueto=$actionItem.getDueTo())
#else
#set($dueto="")
#end
* [#$issue](https://github.com/dadoonet/spring-elasticsearch/issues/$issue): ${action} #if($!issue != ""). #end#if($!dueto != "")Thanks to $dueto. #end

#set($issue="")
#set($dueto="")
#end
#end
## End of main loop
#end
#if ($urlDownload)

For a manual installation, you can download the ${finalName} here:
${urlDownload}
#end

Have fun!
-${developmentTeam}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/BaseTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.pilato.spring.elasticsearch.SSLUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assumptions.assumeFalse;

public abstract class BaseTest {
    private final static Logger staticLogger = LoggerFactory.getLogger(BaseTest.class);
    protected final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    private static RestClient client;

    public final static String DEFAULT_TEST_CLUSTER = "https://127.0.0.1:9200";
    private final static String DEFAULT_TEST_USER = "elastic";
    private final static String DEFAULT_TEST_PASSWORD = "changeme";

    public final static String testCluster = System.getProperty("tests.cluster", DEFAULT_TEST_CLUSTER);
    public final static String testClusterUser = System.getProperty("tests.cluster.user", DEFAULT_TEST_USER);
    public final static String testClusterPass = System.getProperty("tests.cluster.pass", DEFAULT_TEST_PASSWORD);

    private static void testClusterRunning() throws IOException {
        try {
            Response response = client.performRequest(new Request("GET", "/"));
            Map<String, Object> result = new ObjectMapper().readValue(response.getEntity().getContent(), new TypeReference<>() {
            });

            Map<String, Object> asMap = (Map<String, Object>) result.get("version");

            staticLogger.info("Starting integration tests against an external cluster running elasticsearch [{}]",
                    asMap.get("number"));
        } catch (ConnectException e) {
            // If we have an exception here, let's ignore the test
            staticLogger.warn("Integration tests are skipped: [{}]", e.getMessage());
            assumeFalse(e.getMessage().contains("Connection refused"), "Integration tests are skipped");
        } catch (IOException e) {
            staticLogger.error("Full error is", e);
            throw e;
        }
    }


    @BeforeAll
    public static void startElasticsearchClient() {
        try {
            if (client == null) {
                staticLogger.info("Starting tests against {}", testCluster);
                RestClientBuilder builder = RestClient.builder(HttpHost.create(testCluster));
                final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(AuthScope.ANY,
                        new UsernamePasswordCredentials(testClusterUser, testClusterPass));

                builder.setHttpClientConfigCallback(hcb -> {
                    hcb.setDefaultCredentialsProvider(credentialsProvider);
                    if (testCluster.equals(DEFAULT_TEST_CLUSTER)) {
                        hcb.setSSLContext(SSLUtils.yesSSLContext());
                    }
                    return hcb;
                });

                client = builder.build();
                testClusterRunning();
            }
        } catch (Exception e) {
            staticLogger.error("Error", e);
            assumeFalse(true, "Elasticsearch does not seem to run.");
        }
    }

    @AfterAll
    public static void stopClient() throws IOException {
        if (client != null) {
            client.close();
            client = null;
        }
    }

    protected void executeBefore(RestClient client) throws IOException {
        // Do nothing
    }

    @BeforeEach @AfterEach
    public void cleanIndex() throws IOException {
        if (indexName() != null) {
            deleteIndex(indexName());
        }
        for (String otherTestIndex : otherTestIndices()) {
            deleteIndex(otherTestIndex);
        }
        deleteIndex("twitter");
        executeBefore(client);
    }

    private void deleteIndex(String indexName) throws IOException {
        try {
            logger.debug("Removing index {}", indexName);
            client.performRequest(new Request("DELETE", "/" + indexName));
            logger.debug("Removing index {} - ok", indexName);
        } catch (ResponseException e) {
            if (e.getResponse().getStatusLine().getStatusCode() != 404) {
                throw e;
            }
            logger.debug("Removing index {} - not found", indexName);
        }
    }

    /**
     * Overwrite if twitter is not the index name. Can be null if no index should be created
     * @return Index name. Could be null
     */
    protected String indexName() {
        return "twitter";
    }

    /**
     * Overwrite if the test is using multiple indices. Can be null if no other index should be created
     * @return Index name. Could be null
     */
    protected List<String> otherTestIndices() {
        return new ArrayList<>();
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/AbstractAnnotationContextModel.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation;

import fr.pilato.spring.elasticsearch.it.BaseTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public abstract class AbstractAnnotationContextModel extends BaseTest {
    protected AnnotationConfigApplicationContext ctx;

    /**
     * @return list of specific classpath to load if not the default one
     */
    String classpath() {
        return null;
    }

    @BeforeEach
    void startContext() {
        String classpath = classpath();

        if (classpath == null || classpath.isEmpty()) {
            // If not set, the test package name is used.
            classpath = this.getClass().getPackage().getName();
        }

        logger.info("  --> Starting Spring Context on [{}] classpath", classpath);
        ctx = new AnnotationConfigApplicationContext();
        ctx.scan(classpath);
        ctx.refresh();
    }

    @AfterEach
    void stopContext() {
        if (ctx != null) {
            logger.info("  --> Closing Spring Context");
            ctx.close();
        }
    }

    /**
     * Overwrite it if the number of expected shards is not 5
     * @return Number of expected primaries
     */
    protected int expectedShards() {
        return 1;
    }

    /**
     * Overwrite it if the number of expected replicas is not 1
     * @return Number of expected replicas
     */
    protected int expectedReplicas() {
        return 1;
    }

    protected String beanName() {
        return "esClient";
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/AbstractRestAnnotationContextModel.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.core.GetResponse;
import co.elastic.clients.elasticsearch.indices.GetIndicesSettingsResponse;
import fr.pilato.spring.elasticsearch.it.annotation.AbstractAnnotationContextModel;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.StringReader;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

public abstract class AbstractRestAnnotationContextModel extends AbstractAnnotationContextModel {
    protected ElasticsearchClient checkClient(String name) {
        ElasticsearchClient client;

        if (name != null) {
            client = ctx.getBean(name, ElasticsearchClient.class);
        } else {
            client = ctx.getBean(ElasticsearchClient.class);
        }
        assertThat(client, not(nullValue()));
        return client;
    }

    @Test
    public void testFactoriesCreated() throws Exception {
        ElasticsearchClient client = checkClient(beanName());
        checkUseCaseSpecific(client);

        // If an index is expected, let's check it actually exists
        if (indexName() != null) {
            // We test how many shards and replica we have
            assertShardsAndReplicas(client, indexName(), expectedShards(), expectedReplicas());

            // #92: search errors with async created Client
            client.index(ir -> ir.index("twitter").id("1").withJson(new StringReader("{\"foo\":\"bar\"}")));
            GetResponse<Void> response = client.get(gr -> gr.index("twitter").id("1"), Void.class);
            assertThat(response, notNullValue());
        }
    }

    /**
     * Overwrite it to implement use case specific tests
     * @param client Client representing bean named esClient
     */
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws Exception {
    }

    protected void assertShardsAndReplicas(ElasticsearchClient client, String indexName, int expectedShards, int expectedReplicas) throws IOException {
        GetIndicesSettingsResponse settings = client.indices().getSettings(gisr -> gisr.index(indexName));
        assertThat(Integer.parseInt(settings.get(indexName).settings().index().numberOfShards()), is(expectedShards));
        assertThat(Integer.parseInt(settings.get(indexName).settings().index().numberOfReplicas()), is(expectedReplicas));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/RestAppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.SSLUtils;
import org.apache.http.HttpHost;
import org.springframework.context.annotation.Bean;

import java.util.List;

import static fr.pilato.spring.elasticsearch.it.BaseTest.*;

public abstract class RestAppConfig {

	abstract protected void enrichFactory(ElasticsearchClientFactoryBean factory);

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		enrichFactory(factory);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	public static void enrichFactoryWithNodeSettings(ElasticsearchClientFactoryBean factory) {
		factory.setEsNodes(List.of(HttpHost.create(testCluster)));
		factory.setUsername(testClusterUser);
		factory.setPassword(testClusterPass);
		if (testCluster.equals(DEFAULT_TEST_CLUSTER)) {
			factory.setSslContext(SSLUtils.yesSSLContext());
		}
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AliasesTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.aliases;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.indices.get_alias.IndexAliases;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.util.List;
import java.util.Map;

import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.not;

public class AliasesTest extends AbstractRestAnnotationContextModel {

    @Override
    protected List<String> otherTestIndices() {
        return asList("test_1", "test_2");
    }

    @Override
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws Exception {
        Map<String, IndexAliases> response = client.indices().getAlias(gar -> gar.name("test")).result();
        assertThat(response, not(hasKey("test_1")));
        assertThat(response, hasKey("test_2"));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.aliases;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/aliases");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.badclasspath;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/esdoesnotexist");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/BadClasspath7Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.badclasspath;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;


public class BadClasspath7Test extends AbstractRestAnnotationContextModel {
    @Override
    public String indexName() {
        return null;
    }

    @Override
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        assertThat("twitter index should not exist", client.indices().exists(er -> er.index("twitter")).value(), is(false));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.configuration;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/ConfigurationTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.configuration;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

class ConfigurationTest extends AbstractRestAnnotationContextModel {

	@Override
	protected void checkUseCaseSpecific(ElasticsearchClient client) throws Exception {
		// We call the Rest client to make sure it works properly
		client.info();
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.customanalyzers;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/custom-analyzers-12/client");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/CustomAnalyzers12Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.customanalyzers;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;


public class CustomAnalyzers12Test extends AbstractRestAnnotationContextModel {

    @Override
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        assertThat(client.indices().getSettings(gisr -> gisr.index("twitter"))
                .get("twitter").settings().index().analysis().analyzer().get("francais").isCustom(),
                is(true));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.indextemplates;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/index-templates/client");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/IndexTemplatesTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.indextemplates;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;


public class IndexTemplatesTest extends AbstractRestAnnotationContextModel {

    @Override
    protected void executeBefore(RestClient client) throws IOException {
        try {
            client.performRequest(new Request("DELETE", "/_index_template/template_1"));
        } catch (ResponseException ignored) { }
        try {
            client.performRequest(new Request("DELETE", "/_component_template/component1"));
        } catch (ResponseException ignored) { }
        try {
            client.performRequest(new Request("DELETE", "/_component_template/component2"));
        } catch (ResponseException ignored) { }
    }

    @Override
    protected String indexName() {
        return null;
    }

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        boolean existsTemplate = client.indices().existsIndexTemplate(eit -> eit.name("template_1")).value();
        assertThat(existsTemplate, is(true));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.indicesalreadyexist;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/indices-already-exist-86/client");
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/indices-already-exist-86/client");
		factory.afterPropertiesSet();
		return factory.getObject();
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/IndicesAlreadyExistTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.indicesalreadyexist;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;

public class IndicesAlreadyExistTest extends AbstractRestAnnotationContextModel {

    @Override
    protected List<String> otherTestIndices() {
        return Collections.singletonList("badindex");
    }

    @Test
    void testTwoClients() {
        ElasticsearchClient esClient = checkClient("esClient");
        assertThat(esClient, notNullValue());
        ElasticsearchClient esClient2 = checkClient("esClient2");
        assertThat(esClient2, notNullValue());
    }

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.lifecycles;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/lifecycles");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/LifecyclesTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.lifecycles;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;


public class LifecyclesTest extends AbstractRestAnnotationContextModel {

    @Override
    protected void executeBefore(RestClient client) throws IOException {
        try {
            client.performRequest(new Request("DELETE", "/_ilm/policy/policy1"));
        } catch (ResponseException ignored) { }
    }

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        assertThat(client.ilm().getLifecycle(glr -> glr.name("policy1")), notNullValue());
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.manualsettings;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/manual-settings");
		factory.setIndices(new String[]{"twitter"});
		factory.setAliases(new String[]{"alltheworld:twitter"});
		factory.setPipelines(new String[]{"pipeline1"});
		factory.setComponentTemplates(new String[]{"component1"});
		factory.setIndexTemplates(new String[]{"template_1"});
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/ManualSettingsTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.manualsettings;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class ManualSettingsTest extends AbstractRestAnnotationContextModel {
    @Override
    protected void executeBefore(RestClient client) throws IOException {
        try {
            client.performRequest(new Request("DELETE", "/_index_template/template_1"));
        } catch (ResponseException ignored) { }
        try {
            client.performRequest(new Request("DELETE", "/_component_template/component1"));
        } catch (ResponseException ignored) { }
        try {
            client.performRequest(new Request("DELETE", "/_pipeline/pipeline1"));
        } catch (ResponseException ignored) { }
    }

    @Override
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws Exception {
        // Test manual creation of one index even though we have multiple ones in the classpath
        assertThat(client.indices().get(gir -> gir.index("twitter")).result(), hasKey("twitter"));
        assertThat(client.indices().get(gir -> gir.index("foobar").ignoreUnavailable(true)).result(), not(hasKey("twitter")));

        // Test manual creation of one alias even though we have multiple ones in the classpath
        assertThat(client.indices().getAlias(gar -> gar.index("twitter")).result().get("twitter").aliases(), hasKey("alltheworld"));
        assertThat(client.indices().getAlias(gar -> gar.index("twitter")).result().get("twitter").aliases(), not(hasKey("alias")));

        // Test manual creation of one pipeline even though we have multiple ones in the classpath
        assertThat(client.ingest().getPipeline(gpr -> gpr.id("pipeline1")).get("pipeline1"), notNullValue());
        assertThat(client.ingest().getPipeline(gpr -> gpr.id("pipeline2")).get("pipeline2"), nullValue());

        // Test manual creation of one component template even though we have multiple ones in the classpath
        assertThat(client.cluster().getComponentTemplate(gctr -> gctr.name("component1")).componentTemplates(), hasSize(1));
        assertThrows(ElasticsearchException.class, () -> {
            try {
                client.cluster().getComponentTemplate(gctr -> gctr.name("component2"));
            } catch (ElasticsearchException e) {
                assertThat(e.status(), is(404));
                throw e;
            }
        });

        // Test manual creation of one index template even though we have multiple ones in the classpath
        assertThat(client.indices().existsIndexTemplate(eit -> eit.name("template_1")).value(), is(true));
        assertThat(client.indices().existsIndexTemplate(eit -> eit.name("template_2")).value(), is(false));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mapping;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/mapping/client1");
		factory.setForceIndex(false);
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/mapping/client2");
		factory.setMergeSettings(true);
		factory.afterPropertiesSet();
		return factory.getObject();
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/MappingTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mapping;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.mapping.Property;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;


public class MappingTest extends AbstractRestAnnotationContextModel {

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        ElasticsearchClient client2 = checkClient("esClient2");

        Map<String, Property> response = client2.indices()
                .getMapping(gmr -> gmr.index("twitter")).get("twitter").mappings().properties();
        // This one comes from the first mapping
        assertThat(response, hasKey("message"));
        // This one comes from the second mapping
        assertThat(response, hasKey("author"));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mappingconvention;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {

	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/MappingConventionTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mappingconvention;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.mapping.Property;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

public class MappingConventionTest extends AbstractRestAnnotationContextModel {

    @Override
    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        Property property = client.indices().getMapping(gmr -> gmr.index("twitter")).get("twitter").mappings().properties().get("message");
        assertThat(property, notNullValue());
        assertThat(property.text().store(), is(true));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mappingfailed;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig.enrichFactoryWithNodeSettings;

@Configuration
public class AppConfig {

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/mapping-failed/client1");
		factory.setForceIndex(false);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/mapping-failed/client2");
		factory.setMergeSettings(true);
		factory.afterPropertiesSet();
		return factory.getObject();
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/MappingFailedTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.mappingfailed;

import fr.pilato.spring.elasticsearch.it.BaseTest;
import org.elasticsearch.client.ResponseException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
 * We try to merge non merging mapping.
 * An exception should be raised.
 * @author David Pilato aka dadoonet
 *
 */
public class MappingFailedTest extends BaseTest {

	@Override
	public String indexName() {
		return null;
	}

	@Test
	void test_rest_client() {
		assertThrows(BeanCreationException.class, () -> {
			try {
				logger.info("  --> Starting Spring Context on [{}] classpath", this.getClass().getPackage().getName());
				new AnnotationConfigApplicationContext(AppConfig.class);
			} catch (BeanCreationException e) {
				Throwable cause = e.getCause().getCause();
				assertEquals(ResponseException.class, cause.getClass());
				ResponseException responseException = (ResponseException) cause;
				assertThat(responseException.getResponse().getStatusLine().getStatusCode(), is(400));
				throw e;
			}
		});
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.multipleclients;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig.enrichFactoryWithNodeSettings;

@Configuration
public class AppConfig {

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/multiple-clients/client1");
		factory.setForceIndex(false);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/multiple-clients/client2");
		factory.setMergeSettings(true);
		factory.afterPropertiesSet();
		return factory.getObject();
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/MultipleClientsTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.multipleclients;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;

public class MultipleClientsTest extends AbstractRestAnnotationContextModel {

	protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
		ElasticsearchClient client2 = checkClient("esClient2");
		// We test how many shards and replica we have
		// Let's do the same thing with the second client
		// We test how many shards and replica we have
		// We don't expect the number of replicas to be 4 as we won't merge _update_settings.json
		// See #31: https://github.com/dadoonet/spring-elasticsearch/issues/31
		assertShardsAndReplicas(client2, "twitter", 1, 1);
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.pipelines;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/pipelines");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/PipelinesTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.pipelines;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;


public class PipelinesTest extends AbstractRestAnnotationContextModel {

    @Override
    protected void executeBefore(RestClient client) throws IOException {
        try {
            client.performRequest(new Request("DELETE", "/_pipeline/pipeline1"));
        } catch (ResponseException ignored) { }
    }

    @Override
    protected String indexName() {
        return null;
    }

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        assertThat(client.ingest().getPipeline(gpr -> gpr.id("pipeline1")).get("pipeline1"), notNullValue());
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settings13;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/settings-13/client");
		factory.setForceIndex(true);
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/Settings13Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settings13;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;
import java.util.Collections;
import java.util.List;


public class Settings13Test extends AbstractRestAnnotationContextModel {

    @Override
    protected List<String> otherTestIndices() {
        return Collections.singletonList("rss");
    }

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        assertShardsAndReplicas(client, "rss", 1, 1);
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settingsfailed;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig.enrichFactoryWithNodeSettings;

@Configuration
public class AppConfig {

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/settings-failed/client1");
		factory.setForceIndex(false);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/settings-failed/client2");
		factory.setMergeSettings(true);
		factory.afterPropertiesSet();
		return factory.getObject();
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/SettingsFailedTest.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settingsfailed;

import fr.pilato.spring.elasticsearch.it.BaseTest;
import org.elasticsearch.client.ResponseException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
 * We try to merge non merging mapping.
 * An exception should be raised.
 * @author David Pilato aka dadoonet
 *
 */
public class SettingsFailedTest extends BaseTest {

	@Override
	public String indexName() {
		return null;
	}

	@Test
	void test_rest_client() {
		assertThrows(BeanCreationException.class, () -> {
			try {
				logger.info("  --> Starting Spring Context on [{}] classpath", this.getClass().getPackage().getName());
				new AnnotationConfigApplicationContext(AppConfig.class);
			} catch (BeanCreationException e) {
				Throwable cause = e.getCause().getCause();
				assertEquals(ResponseException.class, cause.getClass());
				ResponseException responseException = (ResponseException) cause;
				assertThat(responseException.getResponse().getStatusLine().getStatusCode(), is(400));
				assertThat(responseException.getMessage(), containsString("Can't update non dynamic settings"));
				throw e;
			}
		});
	}
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settingsnomapping21;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/settings-no-mapping-21/client");
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/SettingsNoMapping21Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.settingsnomapping21;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

import java.io.IOException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;


public class SettingsNoMapping21Test extends AbstractRestAnnotationContextModel {

    protected void checkUseCaseSpecific(ElasticsearchClient client) throws IOException {
        // We should have an existing index here
        assertThat(client.indices().get(gir -> gir.index("twitter")).result(), hasKey("twitter"));
    }
}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/shards/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.shards;

import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig extends RestAppConfig {

	@Override
	protected void enrichFactory(ElasticsearchClientFactoryBean factory) {
		factory.setClasspathRoot("/models/root/shards/client");
		factory.setForceIndex(true);
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.updatesettingsdisabled31;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig.enrichFactoryWithNodeSettings;

@Configuration
public class AppConfig {

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/update-settings-31/client1");
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/update-settings-31/client2");
		factory.setMergeSettings(false);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/UpdateSettingsDisabled31Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.updatesettingsdisabled31;

import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

public class UpdateSettingsDisabled31Test extends AbstractRestAnnotationContextModel {

    @Override
    protected int expectedShards() {
        return 2;
    }

    @Override
    protected int expectedReplicas() {
        return 0;
    }

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/AppConfig.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.updatesettingsenabled31;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static fr.pilato.spring.elasticsearch.it.annotation.rest.RestAppConfig.enrichFactoryWithNodeSettings;

@Configuration
public class AppConfig {

	@Bean
	public ElasticsearchClient esClient() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/update-settings-disabled-31/client1");
		factory.afterPropertiesSet();
		return factory.getObject();
	}

	@Bean
	public ElasticsearchClient esClient2() throws Exception {
		ElasticsearchClientFactoryBean factory = new ElasticsearchClientFactoryBean();
		enrichFactoryWithNodeSettings(factory);
		factory.setClasspathRoot("/models/root/update-settings-disabled-31/client2");
		factory.setMergeSettings(true);
		factory.afterPropertiesSet();
		return factory.getObject();
	}

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/UpdateSettings31Test.java
================================================
/*
 * Licensed to David Pilato (the "Author") under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. Author licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package fr.pilato.spring.elasticsearch.it.annotation.rest.updatesettingsenabled31;

import fr.pilato.spring.elasticsearch.it.annotation.rest.AbstractRestAnnotationContextModel;

public class UpdateSettings31Test extends AbstractRestAnnotationContextModel {

    @Override
    protected int expectedShards() {
        return 2;
    }

}


================================================
FILE: src/test/java/fr/pilato/spring/elasticsearch/unit/ClassPathReaderTest.java
================================================
package fr.pilato.spring.elasticsearch.unit;

import fr.pilato.elasticsearch.tools.util.SettingsReader;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;

class ClassPathReaderTest {

    @Test
    void testReadFileInClasspath_ExpectFileReadOk() {
        String url = "classpath-reader-test.txt";
        String contents = SettingsReader.readFileFromClasspath(url);
        assertThat(contents, startsWith("This file is here for testing purposes"));
    }

    @Test
    void testReadFileInClasspath_ExpectFileNotFound_ReturnsNull() {
        String url = "__unknown_file_path_____";
        String contents = SettingsReader.readFileFromClasspath(url);
        assertThat(contents, nullValue());
    }
}


================================================
FILE: src/test/resources/classpath-reader-test.txt
================================================
This file is here for testing purposes. Please don't delete. :)

================================================
FILE: src/test/resources/es/twitter/_settings.json
================================================
{
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true}
    }
  }
}


================================================
FILE: src/test/resources/log4j2.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to David Pilato (the "Author") under one or more contributor
	license agreements. See the NOTICE file distributed with this work for additional
	information regarding copyright ownership. Author licenses this file to you
	under the Apache License, Version 2.0 (the "License"); you may not use this
	file except in compliance with the License. You may obtain a copy of the
	License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
	applicable law or agreed to in writing, software distributed under the License
	is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
	KIND, either express or implied. See the License for the specific language
	governing permissions and limitations under the License. -->
<Configuration status="fatal">
   <Appenders>
      <Console name="CONSOLE" target="SYSTEM_OUT">
         <PatternLayout pattern="%d{ABSOLUTE} %highlight{%-5p} [%c{1.}] %m%n"/>
      </Console>
   </Appenders>
   <Loggers>
      <Logger name="fr.pilato.spring.elasticsearch" level="debug" additivity="false">
         <AppenderRef ref="CONSOLE"/>
      </Logger>
      <Logger name="org.elasticsearch" level="warn" additivity="false">
         <AppenderRef ref="CONSOLE"/>
      </Logger>
      <Logger name="org.springframework" level="warn" additivity="false">
         <AppenderRef ref="CONSOLE"/>
      </Logger>
      <Root level="info">
         <AppenderRef ref="CONSOLE"/>
      </Root>
   </Loggers>
</Configuration>


================================================
FILE: src/test/resources/models/root/aliases/_aliases.json
================================================
{
  "actions" : [
    { "remove": { "index": "test_1", "alias": "test" } },
    { "add":  { "index": "test_2", "alias": "test" } }
  ]
}


================================================
FILE: src/test/resources/models/root/aliases/test_1/_settings.json
================================================
{
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true}
    }
  },
  "aliases": {
    "test": { }
  }
}


================================================
FILE: src/test/resources/models/root/aliases/test_2/_settings.json
================================================
{
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true}
    }
  }
}


================================================
FILE: src/test/resources/models/root/aliases/twitter/_settings.json
================================================
{
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true}
    }
  }
}


================================================
FILE: src/test/resources/models/root/custom-analyzers-12/client/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
                "custom_uax_url_email":{
                    "type":"custom",
                    "tokenizer" : "uax_url_email",
                    "filter" : ["lowercase", "stop"]
                },
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer": "francais"},
			"author" : {"type" : "text", "store" : false, "analyzer": "custom_uax_url_email"}
		}
	}
}


================================================
FILE: src/test/resources/models/root/index-templates/client/_component_templates/component1.json
================================================
{
    "template": {
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date"
                }
            }
        }
    }
}


================================================
FILE: src/test/resources/models/root/index-templates/client/_component_templates/component2.json
================================================
{
    "template": {
        "mappings": {
            "runtime": {
                "day_of_week": {
                    "type": "keyword",
                    "script": {
                        "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
                    }
                }
            }
        }
    }
}


================================================
FILE: src/test/resources/models/root/index-templates/client/_index_templates/template_1.json
================================================
{
    "index_patterns": ["te*", "bar*"],
    "template": {
        "settings": {
            "number_of_shards": 1
        },
        "mappings": {
            "_source": {
                "enabled": true
            },
            "properties": {
                "host_name": {
                    "type": "keyword"
                },
                "created_at": {
                    "type": "date",
                    "format": "EEE MMM dd HH:mm:ss Z yyyy"
                }
            }
        },
        "aliases": {
            "mydata": { }
        }
    },
    "priority": 500,
    "composed_of": ["component1", "component2"],
    "version": 3,
    "_meta": {
        "description": "my custom"
    }
}


================================================
FILE: src/test/resources/models/root/index-with-type/client/twitter/_doc.json
================================================
{
    "properties" : {
        "message" : {"type" : "text", "store" : true}
    }
}


================================================
FILE: src/test/resources/models/root/indices-already-exist-86/client/badindex/_settings.json
================================================
{
  "settings": {
    "number_of_shards" :   2,
    "number_of_replicas" : 2
  },
  "mappings": {
    "properties" : {
      "foo" : {"type" : "text"}
    }
  }
}


================================================
FILE: src/test/resources/models/root/indices-already-exist-86/client/twitter/_settings.json
================================================
{
    "mappings": {
        "properties" : {
            "message" : {"type" : "text", "store" : true}
        }
    }
}


================================================
FILE: src/test/resources/models/root/lifecycles/_index_lifecycles/policy1.json
================================================
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "10d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}


================================================
FILE: src/test/resources/models/root/lifecycles/twitter/_settings.json
================================================
{
	"settings" : {
		"index.lifecycle.name": "policy1"
	}
}


================================================
FILE: src/test/resources/models/root/manual-settings/_aliases.json
================================================
{
  "actions" : [
    { "add":  { "index": "twitter", "alias": "alias" } }
  ]
}


================================================
FILE: src/test/resources/models/root/manual-settings/_component_templates/component1.json
================================================
{
    "template": {
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date"
                }
            }
        }
    }
}


================================================
FILE: src/test/resources/models/root/manual-settings/_component_templates/component2.json
================================================
{
    "template": {
        "mappings": {
            "runtime": {
                "day_of_week": {
                    "type": "keyword",
                    "script": {
                        "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
                    }
                }
            }
        }
    }
}


================================================
FILE: src/test/resources/models/root/manual-settings/_index_templates/template_1.json
================================================
{
    "index_patterns": ["te*", "bar*"],
    "template": {
        "settings": {
            "number_of_shards": 1
        }
    },
    "priority": 100,
    "composed_of": ["component1"],
    "version": 1,
    "_meta": {
        "description": "my custom"
    }
}


================================================
FILE: src/test/resources/models/root/manual-settings/_index_templates/template_2.json
================================================
{
    "index_patterns": ["te*", "bar*"],
    "template": {
        "settings": {
            "number_of_shards": 1
        }
    },
    "priority": 100,
    "composed_of": ["component1"],
    "version": 1,
    "_meta": {
        "description": "my custom should be ignored"
    }
}


================================================
FILE: src/test/resources/models/root/manual-settings/_pipelines/pipeline1.json
================================================
{
  "description": "My optional pipeline1 description",
  "processors": [
  ]
}


================================================
FILE: src/test/resources/models/root/manual-settings/_pipelines/pipeline2.json
================================================
{
  "description": "My optional pipeline2 description",
  "processors": [
  ]
}


================================================
FILE: src/test/resources/models/root/manual-settings/foobar/_settings.json
================================================
{

}


================================================
FILE: src/test/resources/models/root/mapping/client1/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" }
		}
	}
}


================================================
FILE: src/test/resources/models/root/mapping/client2/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
			"author" : {"type" : "text", "store" : false}
		}
	}
}


================================================
FILE: src/test/resources/models/root/mapping-failed/client1/twitter/_settings.json
================================================
{
	"mappings": {
		"properties" : {
			"message" : {"type" : "text" }
		}
	}
}


================================================
FILE: src/test/resources/models/root/mapping-failed/client2/twitter/_update_settings.json
================================================
{
	"mappings": {
		"properties" : {
			"message" : {"type" : "date"}
		}
	}
}


================================================
FILE: src/test/resources/models/root/multiple-clients/client1/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" }
		}
	}
}


================================================
FILE: src/test/resources/models/root/multiple-clients/client2/twitter/_settings.json
================================================
{
    "settings" : {
        "number_of_replicas" : 4,
        "analysis" : {
            "analyzer":{
                "mysimple":{
                    "type":"simple"
                }
            }
        }
    }
}


================================================
FILE: src/test/resources/models/root/no-namespace/client/rss/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"name" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
			"author" : {"type" : "text", "store" : false}
		}
	}
}


================================================
FILE: src/test/resources/models/root/no-namespace/client/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"name" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
			"author" : {"type" : "text", "store" : false}
		}
	}
}


================================================
FILE: src/test/resources/models/root/pipelines/_pipelines/pipeline1.json
================================================
{
  "description": "My optional pipeline description",
  "processors": [
    {
      "set": {
        "description": "My optional processor description",
        "field": "my-long-field",
        "value": 10
      }
    },
    {
      "set": {
        "description": "Set 'my-boolean-field' to true",
        "field": "my-boolean-field",
        "value": true
      }
    },
    {
      "lowercase": {
        "field": "my-keyword-field"
      }
    }
  ]
}


================================================
FILE: src/test/resources/models/root/plugins/client/twitter/_doc.json
================================================
{
    "properties" : {
        "message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
        "author" : {"type" : "text", "store" : false}
    }
}


================================================
FILE: src/test/resources/models/root/plugins/client/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"name" : "french"
				}
			}
		}
	}
}


================================================
FILE: src/test/resources/models/root/rest-client-namespace/client/twitter/_settings.json
================================================
{
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true}
    }
  }
}


================================================
FILE: src/test/resources/models/root/settings-13/client/rss/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
			"author" : {"type" : "text", "store" : false}
		}
	}
}


================================================
FILE: src/test/resources/models/root/settings-13/client/twitter/_settings.json
================================================
{
	"settings" : {
		"analysis":{
			"analyzer":{
				"francais":{
					"type":"custom",
					"tokenizer":"standard",
					"filter":["lowercase", "stop_francais", "fr_stemmer", "asciifolding", "elision"]
				}
			},
			"filter":{
				"stop_francais":{
					"type":"stop",
					"stopwords":["_french_"]
				},
				"fr_stemmer" : {
					"type" : "stemmer",
					"language" : "french"
				}
			}
		}
	},
	"mappings": {
		"properties" : {
			"message" : {"type" : "text", "store" : true, "analyzer" : "francais" },
			"author" : {"type" : "text", "store" : false}
		}
	}
}


================================================
FILE: src/test/resources/models/root/settings-failed/client1/twitter/_settings.json
================================================
{
	"settings" : {
		"index" : {
			"number_of_shards" : 1
		}
	}
}


================================================
FILE: src/test/resources/models/root/settings-failed/client2/twitter/_update_settings.json
================================================
{
    "index" : {
        "number_of_shards" : 4
    }
}


================================================
FILE: src/test/resources/models/root/settings-no-mapping-21/client/twitter/_settings.json
================================================
{
}

================================================
FILE: src/test/resources/models/root/shards/client/twitter/_settings.json
================================================
{
  "settings" : {
    "number_of_shards" : 3,
    "number_of_replicas" : 2
  }
}


================================================
FILE: src/test/resources/models/root/update-settings-31/client1/twitter/_settings.json
================================================
{
  "settings" : {
      "number_of_shards" : 2,
      "number_of_replicas" : 0
  },
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true, "analyzer" : "simple" }
    }
  }
}


================================================
FILE: src/test/resources/models/root/update-settings-31/client2/twitter/_update_settings.json
================================================
{
    "index" : {
        "number_of_replicas" : 1
    }
}


================================================
FILE: src/test/resources/models/root/update-settings-disabled-31/client1/twitter/_settings.json
================================================
{
  "settings" : {
      "number_of_shards" : 2,
      "number_of_replicas" : 0
  },
  "mappings": {
    "properties" : {
      "message" : {"type" : "text", "store" : true, "analyzer" : "simple" }
    }
  }
}


================================================
FILE: src/test/resources/models/root/update-settings-disabled-31/client2/twitter/_update_settings.json
================================================
{
    "index" : {
        "number_of_replicas" : 1
    }
}
Download .txt
gitextract_6pq6rnnj/

├── .github/
│   ├── CODEOWNERS
│   ├── dependabot.yml
│   ├── mergify.yml
│   └── workflows/
│       ├── maven.yml
│       └── pr.yml
├── .gitignore
├── .mvn/
│   ├── jvm.config
│   └── maven.config
├── LICENSE
├── NOTICE
├── README.md
├── pom.xml
└── src/
    ├── main/
    │   ├── java/
    │   │   └── fr/
    │   │       └── pilato/
    │   │           └── spring/
    │   │               └── elasticsearch/
    │   │                   ├── ElasticsearchClientFactoryBean.java
    │   │                   ├── SSLUtils.java
    │   │                   └── Tuple.java
    │   └── resources/
    │       └── org/
    │           └── apache/
    │               └── maven/
    │                   └── plugin/
    │                       └── announcement/
    │                           └── announcement.vm
    └── test/
        ├── java/
        │   └── fr/
        │       └── pilato/
        │           └── spring/
        │               └── elasticsearch/
        │                   ├── it/
        │                   │   ├── BaseTest.java
        │                   │   └── annotation/
        │                   │       ├── AbstractAnnotationContextModel.java
        │                   │       └── rest/
        │                   │           ├── AbstractRestAnnotationContextModel.java
        │                   │           ├── RestAppConfig.java
        │                   │           ├── aliases/
        │                   │           │   ├── AliasesTest.java
        │                   │           │   └── AppConfig.java
        │                   │           ├── badclasspath/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── BadClasspath7Test.java
        │                   │           ├── configuration/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── ConfigurationTest.java
        │                   │           ├── customanalyzers/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── CustomAnalyzers12Test.java
        │                   │           ├── indextemplates/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── IndexTemplatesTest.java
        │                   │           ├── indicesalreadyexist/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── IndicesAlreadyExistTest.java
        │                   │           ├── lifecycles/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── LifecyclesTest.java
        │                   │           ├── manualsettings/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── ManualSettingsTest.java
        │                   │           ├── mapping/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingTest.java
        │                   │           ├── mappingconvention/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingConventionTest.java
        │                   │           ├── mappingfailed/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MappingFailedTest.java
        │                   │           ├── multipleclients/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── MultipleClientsTest.java
        │                   │           ├── pipelines/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── PipelinesTest.java
        │                   │           ├── settings13/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── Settings13Test.java
        │                   │           ├── settingsfailed/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── SettingsFailedTest.java
        │                   │           ├── settingsnomapping21/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── SettingsNoMapping21Test.java
        │                   │           ├── shards/
        │                   │           │   └── AppConfig.java
        │                   │           ├── updatesettingsdisabled31/
        │                   │           │   ├── AppConfig.java
        │                   │           │   └── UpdateSettingsDisabled31Test.java
        │                   │           └── updatesettingsenabled31/
        │                   │               ├── AppConfig.java
        │                   │               └── UpdateSettings31Test.java
        │                   └── unit/
        │                       └── ClassPathReaderTest.java
        └── resources/
            ├── classpath-reader-test.txt
            ├── es/
            │   └── twitter/
            │       └── _settings.json
            ├── log4j2.xml
            └── models/
                └── root/
                    ├── aliases/
                    │   ├── _aliases.json
                    │   ├── test_1/
                    │   │   └── _settings.json
                    │   ├── test_2/
                    │   │   └── _settings.json
                    │   └── twitter/
                    │       └── _settings.json
                    ├── custom-analyzers-12/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── index-templates/
                    │   └── client/
                    │       ├── _component_templates/
                    │       │   ├── component1.json
                    │       │   └── component2.json
                    │       └── _index_templates/
                    │           └── template_1.json
                    ├── index-with-type/
                    │   └── client/
                    │       └── twitter/
                    │           └── _doc.json
                    ├── indices-already-exist-86/
                    │   └── client/
                    │       ├── badindex/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── lifecycles/
                    │   ├── _index_lifecycles/
                    │   │   └── policy1.json
                    │   └── twitter/
                    │       └── _settings.json
                    ├── manual-settings/
                    │   ├── _aliases.json
                    │   ├── _component_templates/
                    │   │   ├── component1.json
                    │   │   └── component2.json
                    │   ├── _index_templates/
                    │   │   ├── template_1.json
                    │   │   └── template_2.json
                    │   ├── _pipelines/
                    │   │   ├── pipeline1.json
                    │   │   └── pipeline2.json
                    │   └── foobar/
                    │       └── _settings.json
                    ├── mapping/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── mapping-failed/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    ├── multiple-clients/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── no-namespace/
                    │   └── client/
                    │       ├── rss/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── pipelines/
                    │   └── _pipelines/
                    │       └── pipeline1.json
                    ├── plugins/
                    │   └── client/
                    │       └── twitter/
                    │           ├── _doc.json
                    │           └── _settings.json
                    ├── rest-client-namespace/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── settings-13/
                    │   └── client/
                    │       ├── rss/
                    │       │   └── _settings.json
                    │       └── twitter/
                    │           └── _settings.json
                    ├── settings-failed/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    ├── settings-no-mapping-21/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── shards/
                    │   └── client/
                    │       └── twitter/
                    │           └── _settings.json
                    ├── update-settings-31/
                    │   ├── client1/
                    │   │   └── twitter/
                    │   │       └── _settings.json
                    │   └── client2/
                    │       └── twitter/
                    │           └── _update_settings.json
                    └── update-settings-disabled-31/
                        ├── client1/
                        │   └── twitter/
                        │       └── _settings.json
                        └── client2/
                            └── twitter/
                                └── _update_settings.json
Download .txt
SYMBOL INDEX (163 symbols across 45 files)

FILE: src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchClientFactoryBean.java
  class ElasticsearchClientFactoryBean (line 157) | public class ElasticsearchClientFactoryBean
    method getLowLevelClient (line 210) | public RestClient getLowLevelClient() {
    method setProperties (line 220) | @Deprecated
    method setForceIndex (line 241) | public void setForceIndex(boolean forceIndex) {
    method setMergeSettings (line 249) | public void setMergeSettings(boolean mergeSettings) {
    method setAutoscan (line 258) | @Deprecated
    method setUsername (line 267) | public void setUsername(String username) {
    method setPassword (line 275) | public void setPassword(String password) {
    method setIndices (line 285) | @Deprecated
    method setAliases (line 296) | @Deprecated
    method setIndexTemplates (line 307) | @Deprecated
    method setComponentTemplates (line 318) | @Deprecated
    method setPipelines (line 329) | @Deprecated
    method setClasspathRoot (line 347) | public void setClasspathRoot(String classpathRoot) {
    method setEsNodes (line 362) | public void setEsNodes(Collection<HttpHost> esNodes) {
    method setEsNodes (line 372) | @Deprecated
    method setSslContext (line 388) | public void setSslContext(SSLContext sslContext) {
    method afterPropertiesSet (line 392) | @Override
    method destroy (line 411) | @Override
    method getObject (line 423) | @Override
    method getObjectType (line 428) | @Override
    method isSingleton (line 433) | @Override
    method computeIndexNames (line 441) | static String[] computeIndexNames(boolean autoscan, String[] resources...
    method discoverFromClasspath (line 466) | static String[] discoverFromClasspath(boolean autoscan, String[] resou...
    method initSettings (line 496) | private void initSettings() throws Exception {
    method initTemplates (line 522) | private void initTemplates() throws Exception {
    method initPipelines (line 550) | private void initPipelines() throws Exception {
    method initLifecycles (line 567) | private void initLifecycles() throws Exception {
    method initAliases (line 584) | private void initAliases() throws Exception {
    method computeAlias (line 614) | static Tuple<String, String> computeAlias(String aliasIndex) {
    method buildElasticsearchLowLevelClient (line 627) | private RestClient buildElasticsearchLowLevelClient() {

FILE: src/main/java/fr/pilato/spring/elasticsearch/SSLUtils.java
  class SSLUtils (line 46) | public class SSLUtils {
    method yesSSLContext (line 55) | public static SSLContext yesSSLContext() {
    method checkCertificatesSSLContext (line 96) | public static SSLContext checkCertificatesSSLContext(String trustStore...
    method createSslContextFromCa (line 117) | public SSLContext createSslContextFromCa(String certPath) {

FILE: src/main/java/fr/pilato/spring/elasticsearch/Tuple.java
  class Tuple (line 22) | public class Tuple<V1, V2> {
    method tuple (line 24) | public static <V1, V2> Tuple<V1, V2> tuple(V1 v1, V2 v2) {
    method Tuple (line 31) | public Tuple(V1 v1, V2 v2) {
    method v1 (line 36) | public V1 v1() {
    method v2 (line 40) | public V2 v2() {
    method toString (line 44) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/BaseTest.java
  class BaseTest (line 50) | public abstract class BaseTest {
    method testClusterRunning (line 64) | private static void testClusterRunning() throws IOException {
    method startElasticsearchClient (line 85) | @BeforeAll
    method stopClient (line 112) | @AfterAll
    method executeBefore (line 120) | protected void executeBefore(RestClient client) throws IOException {
    method cleanIndex (line 124) | @BeforeEach @AfterEach
    method deleteIndex (line 136) | private void deleteIndex(String indexName) throws IOException {
    method indexName (line 153) | protected String indexName() {
    method otherTestIndices (line 161) | protected List<String> otherTestIndices() {

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/AbstractAnnotationContextModel.java
  class AbstractAnnotationContextModel (line 27) | public abstract class AbstractAnnotationContextModel extends BaseTest {
    method classpath (line 33) | String classpath() {
    method startContext (line 37) | @BeforeEach
    method stopContext (line 52) | @AfterEach
    method expectedShards (line 64) | protected int expectedShards() {
    method expectedReplicas (line 72) | protected int expectedReplicas() {
    method beanName (line 76) | protected String beanName() {

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/AbstractRestAnnotationContextModel.java
  class AbstractRestAnnotationContextModel (line 34) | public abstract class AbstractRestAnnotationContextModel extends Abstrac...
    method checkClient (line 35) | protected ElasticsearchClient checkClient(String name) {
    method testFactoriesCreated (line 47) | @Test
    method checkUseCaseSpecific (line 68) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...
    method assertShardsAndReplicas (line 71) | protected void assertShardsAndReplicas(ElasticsearchClient client, Str...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/RestAppConfig.java
  class RestAppConfig (line 32) | public abstract class RestAppConfig {
    method enrichFactory (line 34) | abstract protected void enrichFactory(ElasticsearchClientFactoryBean f...
    method esClient (line 36) | @Bean
    method enrichFactoryWithNodeSettings (line 45) | public static void enrichFactoryWithNodeSettings(ElasticsearchClientFa...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AliasesTest.java
  class AliasesTest (line 34) | public class AliasesTest extends AbstractRestAnnotationContextModel {
    method otherTestIndices (line 36) | @Override
    method checkUseCaseSpecific (line 41) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/BadClasspath7Test.java
  class BadClasspath7Test (line 31) | public class BadClasspath7Test extends AbstractRestAnnotationContextModel {
    method indexName (line 32) | @Override
    method checkUseCaseSpecific (line 37) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/ConfigurationTest.java
  class ConfigurationTest (line 25) | class ConfigurationTest extends AbstractRestAnnotationContextModel {
    method checkUseCaseSpecific (line 27) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/CustomAnalyzers12Test.java
  class CustomAnalyzers12Test (line 31) | public class CustomAnalyzers12Test extends AbstractRestAnnotationContext...
    method checkUseCaseSpecific (line 33) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/IndexTemplatesTest.java
  class IndexTemplatesTest (line 34) | public class IndexTemplatesTest extends AbstractRestAnnotationContextMod...
    method executeBefore (line 36) | @Override
    method indexName (line 49) | @Override
    method checkUseCaseSpecific (line 54) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/AppConfig.java
  class AppConfig (line 28) | @Configuration
    method enrichFactory (line 31) | @Override
    method esClient2 (line 36) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/IndicesAlreadyExistTest.java
  class IndicesAlreadyExistTest (line 32) | public class IndicesAlreadyExistTest extends AbstractRestAnnotationConte...
    method otherTestIndices (line 34) | @Override
    method testTwoClients (line 39) | @Test

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/LifecyclesTest.java
  class LifecyclesTest (line 34) | public class LifecyclesTest extends AbstractRestAnnotationContextModel {
    method executeBefore (line 36) | @Override
    method checkUseCaseSpecific (line 43) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/ManualSettingsTest.java
  class ManualSettingsTest (line 35) | public class ManualSettingsTest extends AbstractRestAnnotationContextMod...
    method executeBefore (line 36) | @Override
    method checkUseCaseSpecific (line 49) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/AppConfig.java
  class AppConfig (line 28) | @Configuration
    method enrichFactory (line 31) | @Override
    method esClient2 (line 37) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/MappingTest.java
  class MappingTest (line 33) | public class MappingTest extends AbstractRestAnnotationContextModel {
    method checkUseCaseSpecific (line 35) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/MappingConventionTest.java
  class MappingConventionTest (line 32) | public class MappingConventionTest extends AbstractRestAnnotationContext...
    method checkUseCaseSpecific (line 34) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/AppConfig.java
  class AppConfig (line 29) | @Configuration
    method esClient (line 32) | @Bean
    method esClient2 (line 42) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/MappingFailedTest.java
  class MappingFailedTest (line 39) | public class MappingFailedTest extends BaseTest {
    method indexName (line 41) | @Override
    method test_rest_client (line 46) | @Test

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/AppConfig.java
  class AppConfig (line 29) | @Configuration
    method esClient (line 32) | @Bean
    method esClient2 (line 42) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/MultipleClientsTest.java
  class MultipleClientsTest (line 27) | public class MultipleClientsTest extends AbstractRestAnnotationContextMo...
    method checkUseCaseSpecific (line 29) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/PipelinesTest.java
  class PipelinesTest (line 34) | public class PipelinesTest extends AbstractRestAnnotationContextModel {
    method executeBefore (line 36) | @Override
    method indexName (line 43) | @Override
    method checkUseCaseSpecific (line 48) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/Settings13Test.java
  class Settings13Test (line 30) | public class Settings13Test extends AbstractRestAnnotationContextModel {
    method otherTestIndices (line 32) | @Override
    method checkUseCaseSpecific (line 37) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/AppConfig.java
  class AppConfig (line 29) | @Configuration
    method esClient (line 32) | @Bean
    method esClient2 (line 42) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/SettingsFailedTest.java
  class SettingsFailedTest (line 40) | public class SettingsFailedTest extends BaseTest {
    method indexName (line 42) | @Override
    method test_rest_client (line 47) | @Test

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/SettingsNoMapping21Test.java
  class SettingsNoMapping21Test (line 31) | public class SettingsNoMapping21Test extends AbstractRestAnnotationConte...
    method checkUseCaseSpecific (line 33) | protected void checkUseCaseSpecific(ElasticsearchClient client) throws...

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/shards/AppConfig.java
  class AppConfig (line 26) | @Configuration
    method enrichFactory (line 29) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/AppConfig.java
  class AppConfig (line 29) | @Configuration
    method esClient (line 32) | @Bean
    method esClient2 (line 41) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/UpdateSettingsDisabled31Test.java
  class UpdateSettingsDisabled31Test (line 24) | public class UpdateSettingsDisabled31Test extends AbstractRestAnnotation...
    method expectedShards (line 26) | @Override
    method expectedReplicas (line 31) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/AppConfig.java
  class AppConfig (line 29) | @Configuration
    method esClient (line 32) | @Bean
    method esClient2 (line 41) | @Bean

FILE: src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/UpdateSettings31Test.java
  class UpdateSettings31Test (line 24) | public class UpdateSettings31Test extends AbstractRestAnnotationContextM...
    method expectedShards (line 26) | @Override

FILE: src/test/java/fr/pilato/spring/elasticsearch/unit/ClassPathReaderTest.java
  class ClassPathReaderTest (line 10) | class ClassPathReaderTest {
    method testReadFileInClasspath_ExpectFileReadOk (line 12) | @Test
    method testReadFileInClasspath_ExpectFileNotFound_ReturnsNull (line 19) | @Test
Condensed preview — 104 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (200K chars).
[
  {
    "path": ".github/CODEOWNERS",
    "chars": 498,
    "preview": "# This file is used to define the code owners for the repository.\n# Each line is a file pattern followed by one or more "
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 473,
    "preview": "version: 2\nupdates:\n# Enable version updates for Maven\n- package-ecosystem: maven\n  directory: \"/\"\n  schedule:\n    inter"
  },
  {
    "path": ".github/mergify.yml",
    "chars": 197,
    "preview": "pull_request_rules:\n  - name: automatic merge on CI success and review\n    conditions:\n      - check-success=build\n     "
  },
  {
    "path": ".github/workflows/maven.yml",
    "chars": 1550,
    "preview": "# This workflow will build a Java project with Maven\n# For more information see: https://help.github.com/actions/languag"
  },
  {
    "path": ".github/workflows/pr.yml",
    "chars": 756,
    "preview": "# This workflow will build a Java project with Maven\n# For more information see: https://help.github.com/actions/languag"
  },
  {
    "path": ".gitignore",
    "chars": 54,
    "preview": "/.project\n/.classpath\n/.settings\n/target\n*.iml\n*.idea\n"
  },
  {
    "path": ".mvn/jvm.config",
    "chars": 47,
    "preview": " -Xmx1024m -Xms1024m -Djava.awt.headless=true\n\n"
  },
  {
    "path": ".mvn/maven.config",
    "chars": 91,
    "preview": "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn\n"
  },
  {
    "path": "LICENSE",
    "chars": 11358,
    "preview": "\n                                 Apache License\n                           Version 2.0, January 2004\n                  "
  },
  {
    "path": "NOTICE",
    "chars": 137,
    "preview": "Copyright (c) David Pilato - 2012 \n\nThis product includes software developed by The Apache Software\nFoundation (http://w"
  },
  {
    "path": "README.md",
    "chars": 20442,
    "preview": "# Spring factories for Elasticsearch\n\n**This project is now archived.** \n\nPlease use [Elasticsearch Beyonder](https://gi"
  },
  {
    "path": "pom.xml",
    "chars": 20659,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "src/main/java/fr/pilato/spring/elasticsearch/ElasticsearchClientFactoryBean.java",
    "chars": 25109,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/main/java/fr/pilato/spring/elasticsearch/SSLUtils.java",
    "chars": 5451,
    "preview": "/*\n * Licensed to Elasticsearch under one or more contributor\n * license agreements. See the NOTICE file distributed wit"
  },
  {
    "path": "src/main/java/fr/pilato/spring/elasticsearch/Tuple.java",
    "chars": 1313,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/main/resources/org/apache/maven/plugin/announcement/announcement.vm",
    "chars": 3510,
    "preview": "## Licensed to the Apache Software Foundation (ASF) under one\n## or more contributor license agreements.  See the NOTICE"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/BaseTest.java",
    "chars": 6393,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/AbstractAnnotationContextModel.java",
    "chars": 2414,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/AbstractRestAnnotationContextModel.java",
    "chars": 3280,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/RestAppConfig.java",
    "chars": 1953,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AliasesTest.java",
    "chars": 1817,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/aliases/AppConfig.java",
    "chars": 1275,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/AppConfig.java",
    "chars": 1275,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/badclasspath/BadClasspath7Test.java",
    "chars": 1537,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/AppConfig.java",
    "chars": 1229,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/configuration/ConfigurationTest.java",
    "chars": 1275,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/AppConfig.java",
    "chars": 1302,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/customanalyzers/CustomAnalyzers12Test.java",
    "chars": 1553,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/AppConfig.java",
    "chars": 1297,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indextemplates/IndexTemplatesTest.java",
    "chars": 2252,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/AppConfig.java",
    "chars": 1755,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/indicesalreadyexist/IndicesAlreadyExistTest.java",
    "chars": 1703,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/AppConfig.java",
    "chars": 1281,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/lifecycles/LifecyclesTest.java",
    "chars": 1795,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/AppConfig.java",
    "chars": 1565,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/manualsettings/ManualSettingsTest.java",
    "chars": 4020,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/AppConfig.java",
    "chars": 1776,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mapping/MappingTest.java",
    "chars": 1822,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/AppConfig.java",
    "chars": 1234,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingconvention/MappingConventionTest.java",
    "chars": 1703,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/AppConfig.java",
    "chars": 1979,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/mappingfailed/MappingFailedTest.java",
    "chars": 2204,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/AppConfig.java",
    "chars": 1985,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/multipleclients/MultipleClientsTest.java",
    "chars": 1655,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/AppConfig.java",
    "chars": 1279,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/pipelines/PipelinesTest.java",
    "chars": 1889,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/AppConfig.java",
    "chars": 1320,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settings13/Settings13Test.java",
    "chars": 1451,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/AppConfig.java",
    "chars": 1982,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsfailed/SettingsFailedTest.java",
    "chars": 2359,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/AppConfig.java",
    "chars": 1309,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/settingsnomapping21/SettingsNoMapping21Test.java",
    "chars": 1490,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/shards/AppConfig.java",
    "chars": 1311,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/AppConfig.java",
    "chars": 1968,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsdisabled31/UpdateSettingsDisabled31Test.java",
    "chars": 1222,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/AppConfig.java",
    "chars": 1984,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/it/annotation/rest/updatesettingsenabled31/UpdateSettings31Test.java",
    "chars": 1135,
    "preview": "/*\n * Licensed to David Pilato (the \"Author\") under one\n * or more contributor license agreements.  See the NOTICE file\n"
  },
  {
    "path": "src/test/java/fr/pilato/spring/elasticsearch/unit/ClassPathReaderTest.java",
    "chars": 839,
    "preview": "package fr.pilato.spring.elasticsearch.unit;\n\nimport fr.pilato.elasticsearch.tools.util.SettingsReader;\nimport org.junit"
  },
  {
    "path": "src/test/resources/classpath-reader-test.txt",
    "chars": 63,
    "preview": "This file is here for testing purposes. Please don't delete. :)"
  },
  {
    "path": "src/test/resources/es/twitter/_settings.json",
    "chars": 110,
    "preview": "{\r\n  \"mappings\": {\r\n    \"properties\" : {\r\n      \"message\" : {\"type\" : \"text\", \"store\" : true}\r\n    }\r\n  }\r\n}\r\n"
  },
  {
    "path": "src/test/resources/log4j2.xml",
    "chars": 1520,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Licensed to David Pilato (the \"Author\") under one or more contributor\n\tlicen"
  },
  {
    "path": "src/test/resources/models/root/aliases/_aliases.json",
    "chars": 137,
    "preview": "{\n  \"actions\" : [\n    { \"remove\": { \"index\": \"test_1\", \"alias\": \"test\" } },\n    { \"add\":  { \"index\": \"test_2\", \"alias\": "
  },
  {
    "path": "src/test/resources/models/root/aliases/test_1/_settings.json",
    "chars": 139,
    "preview": "{\n  \"mappings\": {\n    \"properties\" : {\n      \"message\" : {\"type\" : \"text\", \"store\" : true}\n    }\n  },\n  \"aliases\": {\n   "
  },
  {
    "path": "src/test/resources/models/root/aliases/test_2/_settings.json",
    "chars": 103,
    "preview": "{\n  \"mappings\": {\n    \"properties\" : {\n      \"message\" : {\"type\" : \"text\", \"store\" : true}\n    }\n  }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/aliases/twitter/_settings.json",
    "chars": 103,
    "preview": "{\n  \"mappings\": {\n    \"properties\" : {\n      \"message\" : {\"type\" : \"text\", \"store\" : true}\n    }\n  }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/custom-analyzers-12/client/twitter/_settings.json",
    "chars": 803,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n                \"custom_uax_url_email\":{\n                    \"type\":\"cu"
  },
  {
    "path": "src/test/resources/models/root/index-templates/client/_component_templates/component1.json",
    "chars": 187,
    "preview": "{\n    \"template\": {\n        \"mappings\": {\n            \"properties\": {\n                \"@timestamp\": {\n                  "
  },
  {
    "path": "src/test/resources/models/root/index-templates/client/_component_templates/component2.json",
    "chars": 367,
    "preview": "{\n    \"template\": {\n        \"mappings\": {\n            \"runtime\": {\n                \"day_of_week\": {\n                    "
  },
  {
    "path": "src/test/resources/models/root/index-templates/client/_index_templates/template_1.json",
    "chars": 716,
    "preview": "{\n    \"index_patterns\": [\"te*\", \"bar*\"],\n    \"template\": {\n        \"settings\": {\n            \"number_of_shards\": 1\n     "
  },
  {
    "path": "src/test/resources/models/root/index-with-type/client/twitter/_doc.json",
    "chars": 85,
    "preview": "{\n    \"properties\" : {\n        \"message\" : {\"type\" : \"text\", \"store\" : true}\n    }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/indices-already-exist-86/client/badindex/_settings.json",
    "chars": 163,
    "preview": "{\n  \"settings\": {\n    \"number_of_shards\" :   2,\n    \"number_of_replicas\" : 2\n  },\n  \"mappings\": {\n    \"properties\" : {\n "
  },
  {
    "path": "src/test/resources/models/root/indices-already-exist-86/client/twitter/_settings.json",
    "chars": 121,
    "preview": "{\n    \"mappings\": {\n        \"properties\" : {\n            \"message\" : {\"type\" : \"text\", \"store\" : true}\n        }\n    }\n}"
  },
  {
    "path": "src/test/resources/models/root/lifecycles/_index_lifecycles/policy1.json",
    "chars": 304,
    "preview": "{\n  \"policy\": {\n    \"phases\": {\n      \"warm\": {\n        \"min_age\": \"10d\",\n        \"actions\": {\n          \"forcemerge\": {"
  },
  {
    "path": "src/test/resources/models/root/lifecycles/twitter/_settings.json",
    "chars": 59,
    "preview": "{\n\t\"settings\" : {\n\t\t\"index.lifecycle.name\": \"policy1\"\n\t}\n}\n"
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_aliases.json",
    "chars": 81,
    "preview": "{\n  \"actions\" : [\n    { \"add\":  { \"index\": \"twitter\", \"alias\": \"alias\" } }\n  ]\n}\n"
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_component_templates/component1.json",
    "chars": 187,
    "preview": "{\n    \"template\": {\n        \"mappings\": {\n            \"properties\": {\n                \"@timestamp\": {\n                  "
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_component_templates/component2.json",
    "chars": 367,
    "preview": "{\n    \"template\": {\n        \"mappings\": {\n            \"runtime\": {\n                \"day_of_week\": {\n                    "
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_index_templates/template_1.json",
    "chars": 264,
    "preview": "{\n    \"index_patterns\": [\"te*\", \"bar*\"],\n    \"template\": {\n        \"settings\": {\n            \"number_of_shards\": 1\n     "
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_index_templates/template_2.json",
    "chars": 282,
    "preview": "{\n    \"index_patterns\": [\"te*\", \"bar*\"],\n    \"template\": {\n        \"settings\": {\n            \"number_of_shards\": 1\n     "
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_pipelines/pipeline1.json",
    "chars": 80,
    "preview": "{\n  \"description\": \"My optional pipeline1 description\",\n  \"processors\": [\n  ]\n}\n"
  },
  {
    "path": "src/test/resources/models/root/manual-settings/_pipelines/pipeline2.json",
    "chars": 80,
    "preview": "{\n  \"description\": \"My optional pipeline2 description\",\n  \"processors\": [\n  ]\n}\n"
  },
  {
    "path": "src/test/resources/models/root/manual-settings/foobar/_settings.json",
    "chars": 5,
    "preview": "{\n\n}\n"
  },
  {
    "path": "src/test/resources/models/root/mapping/client1/twitter/_settings.json",
    "chars": 518,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/mapping/client2/twitter/_settings.json",
    "chars": 568,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/mapping-failed/client1/twitter/_settings.json",
    "chars": 79,
    "preview": "{\n\t\"mappings\": {\n\t\t\"properties\" : {\n\t\t\t\"message\" : {\"type\" : \"text\" }\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/test/resources/models/root/mapping-failed/client2/twitter/_update_settings.json",
    "chars": 78,
    "preview": "{\n\t\"mappings\": {\n\t\t\"properties\" : {\n\t\t\t\"message\" : {\"type\" : \"date\"}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/test/resources/models/root/multiple-clients/client1/twitter/_settings.json",
    "chars": 518,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/multiple-clients/client2/twitter/_settings.json",
    "chars": 218,
    "preview": "{\n    \"settings\" : {\n        \"number_of_replicas\" : 4,\n        \"analysis\" : {\n            \"analyzer\":{\n                \""
  },
  {
    "path": "src/test/resources/models/root/no-namespace/client/rss/_settings.json",
    "chars": 564,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/no-namespace/client/twitter/_settings.json",
    "chars": 564,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/pipelines/_pipelines/pipeline1.json",
    "chars": 458,
    "preview": "{\n  \"description\": \"My optional pipeline description\",\n  \"processors\": [\n    {\n      \"set\": {\n        \"description\": \"My"
  },
  {
    "path": "src/test/resources/models/root/plugins/client/twitter/_doc.json",
    "chars": 166,
    "preview": "{\n    \"properties\" : {\n        \"message\" : {\"type\" : \"text\", \"store\" : true, \"analyzer\" : \"francais\" },\n        \"author\""
  },
  {
    "path": "src/test/resources/models/root/plugins/client/twitter/_settings.json",
    "chars": 397,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/rest-client-namespace/client/twitter/_settings.json",
    "chars": 103,
    "preview": "{\n  \"mappings\": {\n    \"properties\" : {\n      \"message\" : {\"type\" : \"text\", \"store\" : true}\n    }\n  }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/settings-13/client/rss/_settings.json",
    "chars": 568,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/settings-13/client/twitter/_settings.json",
    "chars": 568,
    "preview": "{\n\t\"settings\" : {\n\t\t\"analysis\":{\n\t\t\t\"analyzer\":{\n\t\t\t\t\"francais\":{\n\t\t\t\t\t\"type\":\"custom\",\n\t\t\t\t\t\"tokenizer\":\"standard\",\n\t\t\t"
  },
  {
    "path": "src/test/resources/models/root/settings-failed/client1/twitter/_settings.json",
    "chars": 67,
    "preview": "{\n\t\"settings\" : {\n\t\t\"index\" : {\n\t\t\t\"number_of_shards\" : 1\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/test/resources/models/root/settings-failed/client2/twitter/_update_settings.json",
    "chars": 57,
    "preview": "{\n    \"index\" : {\n        \"number_of_shards\" : 4\n    }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/settings-no-mapping-21/client/twitter/_settings.json",
    "chars": 3,
    "preview": "{\n}"
  },
  {
    "path": "src/test/resources/models/root/shards/client/twitter/_settings.json",
    "chars": 82,
    "preview": "{\n  \"settings\" : {\n    \"number_of_shards\" : 3,\n    \"number_of_replicas\" : 2\n  }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/update-settings-31/client1/twitter/_settings.json",
    "chars": 210,
    "preview": "{\n  \"settings\" : {\n      \"number_of_shards\" : 2,\n      \"number_of_replicas\" : 0\n  },\n  \"mappings\": {\n    \"properties\" : "
  },
  {
    "path": "src/test/resources/models/root/update-settings-31/client2/twitter/_update_settings.json",
    "chars": 59,
    "preview": "{\n    \"index\" : {\n        \"number_of_replicas\" : 1\n    }\n}\n"
  },
  {
    "path": "src/test/resources/models/root/update-settings-disabled-31/client1/twitter/_settings.json",
    "chars": 210,
    "preview": "{\n  \"settings\" : {\n      \"number_of_shards\" : 2,\n      \"number_of_replicas\" : 0\n  },\n  \"mappings\": {\n    \"properties\" : "
  },
  {
    "path": "src/test/resources/models/root/update-settings-disabled-31/client2/twitter/_update_settings.json",
    "chars": 59,
    "preview": "{\n    \"index\" : {\n        \"number_of_replicas\" : 1\n    }\n}\n"
  }
]

About this extraction

This page contains the full source code of the dadoonet/spring-elasticsearch GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 104 files (176.7 KB), approximately 45.0k tokens, and a symbol index with 163 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!