elastomer-client 3.2.3 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +46 -0
  3. data/.devcontainer/postCreateCommand.sh +4 -0
  4. data/.github/dependabot.yaml +11 -0
  5. data/.github/workflows/main.yml +45 -0
  6. data/.github/workflows/rubocop.yml +15 -0
  7. data/.gitignore +1 -1
  8. data/.rubocop.yml +13 -65
  9. data/.ruby-version +1 -0
  10. data/CHANGELOG.md +76 -0
  11. data/Gemfile +18 -1
  12. data/README.md +110 -51
  13. data/Rakefile +3 -1
  14. data/docker/compose.yaml +71 -0
  15. data/docker/elasticsearch8plus.yml +13 -0
  16. data/docs/README.md +4 -5
  17. data/docs/bulk_indexing.md +1 -1
  18. data/docs/client.md +20 -33
  19. data/docs/cluster.md +8 -8
  20. data/docs/docs.md +5 -5
  21. data/docs/index.md +4 -4
  22. data/docs/multi_search.md +1 -1
  23. data/docs/notifications.md +3 -3
  24. data/docs/scan_scroll.md +1 -1
  25. data/docs/snapshots.md +1 -1
  26. data/docs/templates.md +1 -1
  27. data/elastomer-client.gemspec +7 -16
  28. data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
  29. data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
  30. data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
  31. data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
  32. data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
  33. data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
  34. data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
  35. data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
  36. data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
  37. data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
  38. data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
  39. data/lib/elastomer_client/client/reindex.rb +34 -0
  40. data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
  41. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
  42. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
  43. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
  44. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
  45. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +5 -3
  46. data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
  47. data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
  48. data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
  49. data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
  50. data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
  51. data/lib/elastomer_client/client/update_by_query.rb +50 -0
  52. data/lib/{elastomer → elastomer_client}/client.rb +51 -62
  53. data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
  54. data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
  55. data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
  56. data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
  57. data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
  58. data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
  59. data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
  60. data/lib/elastomer_client/version.rb +9 -0
  61. data/lib/elastomer_client/version_support.rb +24 -0
  62. data/script/bootstrap +4 -2
  63. data/script/console +3 -1
  64. data/script/generate-rest-api-spec +77 -22
  65. data/test/assertions.rb +32 -39
  66. data/test/client/bulk_test.rb +166 -141
  67. data/test/client/cluster_test.rb +35 -13
  68. data/test/client/docs_test.rb +387 -274
  69. data/test/client/errors_test.rb +38 -40
  70. data/test/client/index_test.rb +243 -202
  71. data/test/client/multi_percolate_test.rb +46 -41
  72. data/test/client/multi_search_test.rb +122 -67
  73. data/test/client/native_delete_by_query_test.rb +96 -88
  74. data/test/client/nodes_test.rb +21 -10
  75. data/test/client/percolator_test.rb +19 -14
  76. data/test/client/reindex_test.rb +100 -0
  77. data/test/client/repository_test.rb +31 -19
  78. data/test/client/rest_api_spec/api_spec_test.rb +13 -11
  79. data/test/client/rest_api_spec/rest_api_test.rb +9 -7
  80. data/test/client/scroller_test.rb +44 -70
  81. data/test/client/snapshot_test.rb +38 -21
  82. data/test/client/stubbed_client_test.rb +7 -4
  83. data/test/client/tasks_test.rb +12 -17
  84. data/test/client/template_test.rb +34 -13
  85. data/test/client/update_by_query_test.rb +137 -0
  86. data/test/client_test.rb +158 -92
  87. data/test/core_ext/time_test.rb +14 -12
  88. data/test/middleware/encode_json_test.rb +18 -7
  89. data/test/middleware/opaque_id_test.rb +18 -14
  90. data/test/middleware/parse_json_test.rb +17 -9
  91. data/test/mock_response.rb +30 -0
  92. data/test/notifications_test.rb +15 -8
  93. data/test/test_helper.rb +40 -97
  94. data/test/version_support_test.rb +13 -78
  95. metadata +60 -208
  96. data/.overcommit.yml +0 -5
  97. data/.travis.yml +0 -34
  98. data/docker/docker-compose.cibuild.yml +0 -8
  99. data/docker/docker-compose.es24.yml +0 -34
  100. data/docker/docker-compose.es56.yml +0 -37
  101. data/docs/warmers.md +0 -3
  102. data/lib/elastomer/client/app_delete_by_query.rb +0 -144
  103. data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
  104. data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
  105. data/lib/elastomer/client/warmer.rb +0 -98
  106. data/lib/elastomer/version.rb +0 -7
  107. data/lib/elastomer/version_support.rb +0 -182
  108. data/script/cibuild +0 -103
  109. data/script/cibuild-elastomer-client +0 -1
  110. data/script/cibuild-elastomer-client-es24 +0 -8
  111. data/script/cibuild-elastomer-client-es56 +0 -8
  112. data/test/client/app_delete_by_query_test.rb +0 -192
  113. data/test/client/es_5_x_warmer_test.rb +0 -13
  114. data/test/client/warmer_test.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2120602479977d001a0c4b2cecaa0b270acd2b65f9b293168b24f46e94b5cc0d
4
- data.tar.gz: 506fd065a16ea197d0bb7b1b8ca3a9f304d33881d934dcc681f3884ce7554c78
3
+ metadata.gz: 49da91bf2c259b9b77ed76d66fa001aa4192432225090bb62ff9d74f8173f8dc
4
+ data.tar.gz: 2d519500cced0a8783a9fd5b77853d935cc3b99f35e8be981e5e1e23b55d9632
5
5
  SHA512:
6
- metadata.gz: 991d2089b80e8e9d708e3539bd7cf6bce95d540cdbf6e75290594cc994a79c549147b264237971edbfe49771ca93845cd626e99e3f076560735415281bf1b546
7
- data.tar.gz: c151d7c2629bebd56c5134cc45864210e61757bf35b44d04099e25690b6d9cdbe7254b5fed6b1d85e948b407ca1aa2a192302a8278ac473fc1c997e0728ef224
6
+ metadata.gz: 2f0f879414271cf6f861bfcf256ec6af824a60c2603dbb48dc2297ecffae55f969e7947e8c9cfc0469239c15fe4b9754721279886def527eb89658a549f085fb
7
+ data.tar.gz: 42cd80d2c67d119767451b524543f73cc1af3ffda4088186cfac8daa99970849655c05ed5382e7ab689a71e1a5c8e4c6b620fbaf66a91693e4afad7e186900ff
@@ -0,0 +1,46 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/universal
3
+ {
4
+ "name": "github/elastomer-client",
5
+ "image": "mcr.microsoft.com/devcontainers/ruby:0-3-bullseye",
6
+
7
+ // Features to add to the dev container. More info: https://containers.dev/features.
8
+ "features": {
9
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {},
10
+ "ghcr.io/meaningful-ooo/devcontainer-features/homebrew:2": {},
11
+ "ghcr.io/guiyomh/features/vim:0": {},
12
+ "ghcr.io/jungaretti/features/ripgrep:1": {}
13
+ },
14
+
15
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
16
+ // "forwardPorts": [],
17
+
18
+ // Use 'postCreateCommand' to run commands after the container is created.
19
+ "postCreateCommand": ".devcontainer/postCreateCommand.sh",
20
+
21
+ // Configure tool-specific properties.
22
+ "customizations": {
23
+ "vscode": {
24
+ "extensions": [
25
+ "github.copilot",
26
+ "misogi.ruby-rubocop",
27
+ "mutantdino.resourcemonitor",
28
+ "rebornix.ruby",
29
+ "wingrunr21.vscode-ruby",
30
+ "eamodio.gitlens",
31
+ "miguel-savignano.ruby-symbols",
32
+ "KoichiSasada.vscode-rdbg"
33
+ ],
34
+ "settings": {
35
+ "files.watcherExclude": {
36
+ "**/vendor": true,
37
+ "**/.git": true,
38
+ "**/tmp": true
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
45
+ // "remoteUser": "root"
46
+ }
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ script/bootstrap
@@ -0,0 +1,11 @@
1
+ ---
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: 'bundler'
5
+ directory: '/'
6
+ schedule:
7
+ interval: 'weekly'
8
+ - package-ecosystem: 'github-actions'
9
+ directory: '/'
10
+ schedule:
11
+ interval: 'weekly'
@@ -0,0 +1,45 @@
1
+ name: CI tests
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['3.2']
15
+ ES_VERSION: ['8.13.2']
16
+ include:
17
+ - ES_VERSION: '8.13.2'
18
+ ES_DOWNLOAD_URL: >-
19
+ https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.13.2-linux-x86_64.tar.gz
20
+ steps:
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - uses: actions/checkout@v4
26
+ - name: Cache Elasticsearch
27
+ id: cache-elasticsearch
28
+ uses: actions/cache@v4
29
+ env:
30
+ cache-name: cache-elasticsearch
31
+ with:
32
+ path: ./elasticsearch-${{ matrix.ES_VERSION }}
33
+ key: ${{ env.cache-name }}-${{ matrix.ES_VERSION }}
34
+ - if: ${{ steps.cache-elasticsearch.outputs.cache-hit != 'true' }}
35
+ name: Download Elasticsearch
36
+ run: |
37
+ wget ${{ matrix.ES_DOWNLOAD_URL }}
38
+ tar -xzf elasticsearch-*.tar.gz
39
+ - if: ${{ matrix.ES_VERSION != '5.6.15' }}
40
+ name: Run Elasticsearch
41
+ run: './elasticsearch-${{ matrix.ES_VERSION }}/bin/elasticsearch -d -Expack.security.enabled=false'
42
+ - run: gem install bundler
43
+ - run: bundle install
44
+ - run: script/poll-for-es
45
+ - run: bundle exec rake test
@@ -0,0 +1,15 @@
1
+ name: Rubocop
2
+ on:
3
+ pull_request:
4
+ branches:
5
+ - main
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: '3.2'
14
+ bundler-cache: true
15
+ - run: bundle exec rubocop
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /vendor/gems
4
4
  /.bundle
5
5
  /.rbenv-version
6
- /.ruby-version
7
6
  /vendor/cache/*.gem
8
7
  /coverage
9
8
  Gemfile.lock
@@ -11,3 +10,4 @@ Gemfile.lock
11
10
  tags
12
11
  .byebug_history
13
12
  *.swp
13
+ /tmp
data/.rubocop.yml CHANGED
@@ -12,72 +12,20 @@
12
12
  #
13
13
  # If you disable a check, document why.
14
14
 
15
- AllCops:
16
- DisabledByDefault: true
17
-
18
- StringLiterals:
19
- EnforcedStyle: double_quotes
20
- Severity: error
21
-
22
- HashSyntax:
23
- EnforcedStyle: hash_rockets
24
- Severity: error
25
-
26
- AlignHash:
27
- SupportedLastArgumentHashStyles: always_ignore
28
-
29
- AlignParameters:
30
- Enabled: false # This is usually true, but we often want to roll back to
31
- # the start of a line.
15
+ inherit_gem:
16
+ rubocop-github:
17
+ - config/default.yml # generic Ruby rules and cops
32
18
 
33
- Attr:
34
- Enabled: false # We have no styleguide guidance here, and it seems to be
35
- # in frequent use.
19
+ require:
20
+ - rubocop-minitest
21
+ - rubocop-performance
22
+ - rubocop-rake
36
23
 
37
- ClassAndModuleChildren:
38
- Enabled: false # module X<\n>module Y is just as good as module X::Y.
39
-
40
- Documentation:
41
- Exclude:
42
- - !ruby/regexp /test\/*.rb/
43
-
44
- ClassLength:
24
+ AllCops:
25
+ NewCops: enable
45
26
  Exclude:
46
- - !ruby/regexp /test\/*.rb/
47
-
48
- PercentLiteralDelimiters:
49
- PreferredDelimiters:
50
- '%w': '{}'
51
-
52
- LineLength:
53
- Max: 79
54
- Severity: warning
55
-
56
- MultilineTernaryOperator:
57
- Severity: error
58
-
59
- UnreachableCode:
60
- Severity: error
61
-
62
- AndOr:
63
- Severity: error
64
-
65
- EndAlignment:
66
- Severity: error
67
-
68
- IndentationWidth:
69
- Severity: error
70
-
71
- MethodLength:
72
- CountComments: false # count full line comments?
73
- Max: 20
74
- Severity: error
75
-
76
- Alias:
77
- Enabled: false # We have no guidance on alias vs alias_method
78
-
79
- RedundantSelf:
80
- Enabled: false # Sometimes a self.field is a bit more clear
27
+ - 'lib/elastomer_client/client/rest_api_spec/api_spec_*.rb' # Exclude generated ApiSpec files
28
+ - 'vendor/**/*'
81
29
 
82
- IfUnlessModifier:
83
- Enabled: false
30
+ Metrics/MethodLength:
31
+ Max: 25
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,79 @@
1
+ ## 6.2.1 (2024-12-10)
2
+ - Add support for rethrottling reindex tasks
3
+
4
+ ## 6.2.0 (2024-11-06)
5
+ - Add support for reindex API
6
+ - Remove CI checks for ES 5.6.15
7
+
8
+ ## 6.1.1 (2024-06-05)
9
+ - Unlock faraday_middleware version to allow 1.x
10
+
11
+ ## 6.1.0 (2024-04-09)
12
+ - Replace `Faraday::Error::*` with `Faraday::*` error classes
13
+ - Handle all `Faraday::Error` instead of `Faraday::Error::ClientError`
14
+ - Unlock faraday version to allow 1.0.0
15
+ - Bump the minimum version of faraday and faraday middleware
16
+
17
+ ## 6.0.3 (2024-04-05)
18
+ - Add ES 8.13 REST API spec
19
+ - Update CI and development versions from 8.7.0 to 8.13.0
20
+
21
+ ## 6.0.2 (2024-01-24)
22
+ - Change Opaque ID error handling to not throw OpaqueIDError for 5xx responses
23
+
24
+ ## 6.0.1 (2024-01-09)
25
+ - Move Opaque ID middleware to the end of the Faraday middleware chain
26
+
27
+ ## 6.0.0 (2023-12-08)
28
+ - Remove default retry logic, requiring consumers to implement their own
29
+ - Remove support for ES 7
30
+ - Move to support only the latest Ruby version
31
+
32
+ ## 5.2.0 (2023-11-07)
33
+ - Allow passing a Faraday connection configuration block to the client.
34
+
35
+ ## 5.1.0 (2023-09-29)
36
+ - Remove logic extracting parameters from document in bulk requests. Parameters now must be sent separately from the document to be parsed correctly.
37
+
38
+ ## 5.0.5 (2023-08-08)
39
+ - Replace usage of "found" field by "result" in tests for the delete API (#275)
40
+ - Reduce the noise of the client during an inspect call by hiding connection info (#276)
41
+ - Rename MiniTest to Minitest (#277)
42
+
43
+ ## 5.0.4 (2023-06-20)
44
+ - Remove support for `timestamp` and `ttl` index parameters
45
+
46
+ ## 5.0.3 (2023-06-14)
47
+ - Allow deprecated underscored parameters to work for Bulk API for versions ES 7+.
48
+ - Allow non-underscored parameters to work for Bulk API for version ES 5.
49
+
50
+ ## 5.0.2 (2023-05-31)
51
+ - Add ES 8.7 REST API spec
52
+ - Remove deprecated `type` parameter from `search_shards` API
53
+
54
+ ## 5.0.1 (2023-04-26)
55
+ - Fix bug in bulk API preventing string `_id` from being removed if empty
56
+ - Remove `_type` from document body during bulk requests for versions ES 7+
57
+
58
+ ## 5.0.0 (2023-04-17)
59
+ - Rename Elastomer to ElastomerClient (and elastomer to elastomer_client)
60
+
61
+ ## 4.0.3 (2023-04-07)
62
+ - Fix query values specified in path get removed when query values are specified with params (#261)
63
+ - Add support for `update_by_query` (#263)
64
+
65
+ ## 4.0.2 (2023-03-03)
66
+ - Fix ES 7+ handling of params like `routing` that were prefixed with an underscore in earlier versions
67
+
68
+ ## 4.0.1 (2023-02-10)
69
+ - Fix a bug in the bulk API interface that prevents a version check from working correctly
70
+
71
+ ## 4.0.0 (2023-02-10)
72
+ - Add ES 7 and ES 8 compatibility for existing functionality
73
+ - Remove ES 2 support
74
+ - Add support for newer Ruby versions (3.0, 3.1, 3.2)
75
+ - Remove support for older Ruby versions (< 3.0)
76
+
1
77
  ## 3.2.3 (2020-02-26)
2
78
  - Fix warnings in Ruby 2.7 whan passing a Hash to a method that is expecting keyword arguments
3
79
 
data/Gemfile CHANGED
@@ -1,5 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
5
- gem "simplecov", :require => false, :group => :development, :platform => :ruby_19
7
+ group :development do
8
+ gem "activesupport", ">= 7.0"
9
+ gem "bundler", "~> 2.0"
10
+ gem "debug", "~> 1.7"
11
+ gem "minitest", "~> 5.17"
12
+ gem "minitest-focus", "~> 1.3"
13
+ gem "rake"
14
+ gem "rubocop", "~> 1.63.0"
15
+ gem "rubocop-github", "~> 0.20.0"
16
+ gem "rubocop-minitest", "~> 0.35.0"
17
+ gem "rubocop-performance", "~> 1.21.0"
18
+ gem "rubocop-rake", "~> 0.6.0"
19
+ gem "simplecov", require: false
20
+ gem "spy", "~> 1.0"
21
+ gem "webmock", "~> 3.5"
22
+ end
data/README.md CHANGED
@@ -1,34 +1,23 @@
1
- # Elastomer Client [![Build Status](https://travis-ci.org/github/elastomer-client.svg?branch=master)](https://travis-ci.org/github/elastomer-client)
1
+ # ElastomerClient [![CI build Workflow](https://github.com/github/elastomer-client/actions/workflows/main.yml/badge.svg)](https://github.com/github/elastomer-client/actions/workflows/main.yml)
2
2
 
3
3
  Making a stupid simple Elasticsearch client so your project can be smarter!
4
4
 
5
- ## Getting Started
6
-
7
- Get started by cloning and running a few scripts:
8
-
9
- ```
10
- $ git clone https://github.com/github/elastomer-client.git
11
- $ cd elastomer-client
12
- $ script/bootstrap
13
- $ bundle exec rake test
14
- ```
15
-
16
5
  ## Client
17
6
 
18
7
  The client provides a one-to-one mapping to the Elasticsearch [API
19
8
  endpoints](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html).
20
9
  The API is decomposed into logical sections and accessed according to what you
21
10
  are trying to accomplish. Each logical section is represented as a [client
22
- class](lib/elastomer/client) and a top-level accessor is provided for each.
11
+ class](lib/elastomer_client/client) and a top-level accessor is provided for each.
23
12
 
24
13
  #### Cluster
25
14
 
26
15
  API endpoints dealing with cluster level information and settings are found in
27
- the [Cluster](lib/elastomer/client/cluster.rb) class.
16
+ the [Cluster](lib/elastomer_client/client/cluster.rb) class.
28
17
 
29
18
  ```ruby
30
- require 'elastomer/client'
31
- client = Elastomer::Client.new
19
+ require 'elastomer_client/client'
20
+ client = ElastomerClient::Client.new
32
21
 
33
22
  # the current health summary
34
23
  client.cluster.health
@@ -42,80 +31,150 @@ client.cluster.templates
42
31
 
43
32
  #### Index
44
33
 
45
- The methods in the [Index](lib/elastomer/client/index.rb) class deal with the
34
+ The methods in the [Index](lib/elastomer_client/client/index.rb) class deal with the
46
35
  management of indexes in the cluster. This includes setting up type mappings
47
36
  and adjusting settings. The actual indexing and search of documents are
48
37
  handled by the Docs class (discussed next).
49
38
 
50
39
  ```ruby
51
- require 'elastomer/client'
52
- client = Elastomer::Client.new
40
+ require 'elastomer_client/client'
41
+ client = ElastomerClient::Client.new
53
42
 
54
- index = client.index('twitter')
43
+ index = client.index('books')
55
44
  index.create(
56
45
  :settings => { 'index.number_of_shards' => 3 },
57
46
  :mappings => {
58
- :tweet => {
59
- :_source => { :enabled => true },
60
- :_all => { :enabled => false },
61
- :properties => {
62
- :author => { :type => 'string', :index => 'not_analyzed' },
63
- :tweet => { :type => 'string', :analyze => 'standard' }
64
- }
47
+ :_source => { :enabled => true },
48
+ :properties => {
49
+ :author => { :type => 'keyword' },
50
+ :title => { :type => 'text' }
65
51
  }
66
52
  }
67
53
  )
68
54
 
69
55
  index.exists?
70
56
 
71
- index.exists? :type => 'tweet'
72
-
73
57
  index.delete
74
58
  ```
75
59
 
76
60
  #### Docs
77
61
 
78
- The [Docs](lib/elastomer/client/docs.rb) class handles the indexing and
62
+ The [Docs](lib/elastomer_client/client/docs.rb) class handles the indexing and
79
63
  searching of documents. Each instance is scoped to an index and optionally a
80
64
  document type.
81
65
 
82
66
  ```ruby
83
- require 'elastomer/client'
84
- client = Elastomer::Client.new
67
+ require 'elastomer_client/client'
68
+ client = ElastomerClient::Client.new
85
69
 
86
- docs = client.docs('twitter')
70
+ docs = client.docs('books')
87
71
 
88
72
  docs.index({
89
73
  :_id => 1,
90
- :_type => 'tweet',
91
- :author => '@pea53',
92
- :tweet => 'announcing Elastomer, the stupid simple Elasticsearch client'
74
+ :author => 'Mark Twain',
75
+ :title => 'The Adventures of Huckleberry Finn'
93
76
  })
94
77
 
95
- docs.search({:query => {:match_all => {}}}, :size => 0)
78
+ docs.search({:query => {:match_all => {}}})
96
79
  ```
97
80
 
98
81
  #### Performance
99
82
 
100
- By default Elastomer uses Net::HTTP (via Faraday) to communicate with
83
+ By default ElastomerClient uses Net::HTTP (via Faraday) to communicate with
101
84
  Elasticsearch. You may find that Excon performs better for your use. To enable
102
- Excon, add it to your bundle and then change your Elastomer initialization
85
+ Excon, add it to your bundle and then change your ElastomerClient initialization
103
86
  thusly:
104
87
 
105
88
  ```ruby
106
- Elastomer::Client.new(url: YOUR_ES_URL, adapter: :excon)
89
+ ElastomerClient::Client.new(url: YOUR_ES_URL, adapter: :excon)
90
+ ```
91
+
92
+ #### Retries
93
+
94
+ You can add retry logic to your Elastomer client connection using Faraday's Retry middleware. The `ElastomerClient::Client.new` method can accept a block, which you can use to customize the Faraday connection. Here's an example:
95
+
96
+ ```ruby
97
+ retry_options = {
98
+ max: 2,
99
+ interval: 0.05,
100
+ methods: [:get]
101
+ }
102
+
103
+ ElastomerClient::Client.new do |connection|
104
+ connection.request :retry, retry_options
105
+ end
106
+ ```
107
+
108
+ ## Compatibility
109
+
110
+ This client is tested against:
111
+
112
+ - Ruby version 3.2
113
+ - Elasticsearch versions 5.6 and 8.13
114
+
115
+ ## Development
116
+
117
+ Get started by cloning and running a few scripts:
118
+
119
+ - [ElastomerClient ](#elastomerclient-)
120
+ - [Client](#client)
121
+ - [Cluster](#cluster)
122
+ - [Index](#index)
123
+ - [Docs](#docs)
124
+ - [Performance](#performance)
125
+ - [Compatibility](#compatibility)
126
+ - [Development](#development)
127
+ - [Bootstrap the project](#bootstrap-the-project)
128
+ - [Start an Elasticsearch server in Docker](#start-an-elasticsearch-server-in-docker)
129
+ - [Run tests against a version of Elasticsearch](#run-tests-against-a-version-of-elasticsearch)
130
+ - [Releasing](#releasing)
131
+
132
+ ### Bootstrap the project
133
+
134
+ ```
135
+ script/bootstrap
136
+ ```
137
+
138
+ ### Start an Elasticsearch server in Docker
139
+
140
+ To run ES 5 and ES 8:
141
+ ```
142
+ docker compose --project-directory docker --profile all up
143
+ ```
144
+
145
+ To run only ES 8:
146
+ ```
147
+ docker compose --project-directory docker --profile es8 up
148
+ ```
149
+
150
+ To run only ES 5:
151
+ ```
152
+ docker compose --project-directory docker --profile es5 up
153
+ ```
154
+
155
+ ### Run tests against a version of Elasticsearch
156
+
157
+ ES 8
158
+ ```
159
+ ES_PORT=9208 rake test
160
+ ```
161
+
162
+ ES 5
163
+ ```
164
+ ES_PORT=9205 rake test
107
165
  ```
108
166
 
109
167
  ## Releasing
110
168
 
111
- 1. Create a new branch from `master`
112
- 2. Bump the version number in `lib/elastomer/version.rb`
113
- 3. Update `CHANGELOG.md` with info about the new version
114
- 4. Execute `bin/rake build`. This will place a new gem file in the `pkg/` folder.
115
- 5. Run `gem install pkg/elastomer-client-{VERSION}.gem` to install the new gem locally
116
- 6. Start an `irb` session, `require "elastomer/client"` and make sure things work as you expect
117
- 7. Once everything is working as you expect, commit the version bump and open a PR
118
- 8. Once you get approval and merge it to master, pull down a fresh copy of master and then...
119
- 9. Run `rake release`
120
- 10. If necessary, manually push the new version to rubygems.org
121
- 11. 🕺 💃 🎉
169
+ 1. Create a new branch from `main`
170
+ 1. Bump the version number in `lib/elastomer/version.rb`
171
+ 1. Update `CHANGELOG.md` with info about the new version
172
+ 1. Commit your changes and tag the commit with a version number starting with the prefix "v" e.g. `v4.0.2`
173
+ 1. Execute `rake build`. This will place a new gem file in the `pkg/` folder.
174
+ 1. Run `gem install pkg/elastomer-client-{VERSION}.gem` to install the new gem locally
175
+ 1. Start an `irb` session, `require "elastomer/client"` and make sure things work as you expect
176
+ 1. Once everything is working as you expect, push both your commit and your tag, and open a pull request
177
+ 1. Request review from a maintainer and wait for the pull request to be approved. Once it is approved, you can merge it to `main` yourself. After that, pull down a fresh copy of `main` and then...
178
+ 1. [Optional] If you intend to release a new version to Rubygems, run `rake release`
179
+ 1. [Optional] If necessary, manually push the new version to rubygems.org
180
+ 1. 🕺 💃 🎉
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  require "rake/testtask"
@@ -6,7 +8,7 @@ Rake::TestTask.new do |t|
6
8
  t.test_files = FileList["test/**/*_test.rb"]
7
9
  end
8
10
 
9
- task :default => :test
11
+ task default: :test
10
12
 
11
13
  namespace :actions do
12
14
  desc "list valid actions"
@@ -0,0 +1,71 @@
1
+ version: "3"
2
+
3
+ services:
4
+ elasticsearch8.13:
5
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.13.2
6
+ container_name: es8.13
7
+ profiles: ["es8", "all"]
8
+ environment:
9
+ - cluster.name=elastomer8.13
10
+ - bootstrap.memory_lock=true
11
+ - discovery.type=single-node
12
+ - xpack.security.enabled=false
13
+ - xpack.watcher.enabled=false
14
+ - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
15
+ ulimits:
16
+ memlock:
17
+ soft: -1
18
+ hard: -1
19
+ nofile:
20
+ soft: 65536
21
+ hard: 65536
22
+ mem_limit: 2g
23
+ cap_add:
24
+ - IPC_LOCK
25
+ volumes:
26
+ - esrepos8:/usr/share/elasticsearch/repos
27
+ - ./elasticsearch8plus.yml:/usr/share/elasticsearch/config/elasticsearch.yml
28
+ ports:
29
+ - 127.0.0.1:${ES_8_PORT:-9208}:9200
30
+
31
+ elasticsearch5.6:
32
+ image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
33
+ container_name: es5.6
34
+ profiles: ["es5", "all"]
35
+ environment:
36
+ - cluster.name=elastomer5.6
37
+ - bootstrap.memory_lock=true
38
+ - discovery.type=single-node
39
+ - xpack.monitoring.enabled=false
40
+ - xpack.security.enabled=false
41
+ - xpack.watcher.enabled=false
42
+ - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
43
+ ulimits:
44
+ memlock:
45
+ soft: -1
46
+ hard: -1
47
+ nofile:
48
+ soft: 65536
49
+ hard: 65536
50
+ mem_limit: 1g
51
+ cap_add:
52
+ - IPC_LOCK
53
+ volumes:
54
+ - esrepos5:/usr/share/elasticsearch/repos
55
+ - ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
56
+ ports:
57
+ - 127.0.0.1:${ES_5_PORT:-9205}:9200
58
+
59
+ volumes:
60
+ esrepos8:
61
+ driver: local
62
+ driver_opts:
63
+ device: tmpfs
64
+ type: tmpfs
65
+ o: size=100m,uid=102,gid=102
66
+ esrepos5:
67
+ driver: local
68
+ driver_opts:
69
+ device: tmpfs
70
+ type: tmpfs
71
+ o: size=100m,uid=102,gid=102
@@ -0,0 +1,13 @@
1
+ cluster.name: "docker-cluster"
2
+
3
+ network.host: 0.0.0.0
4
+
5
+ path:
6
+ data: /usr/share/elasticsearch/data
7
+ logs: /usr/share/elasticsearch/logs
8
+ repo: /usr/share/elasticsearch/repos
9
+
10
+ transport.port: 9300
11
+ http.port: 9200
12
+ http.max_content_length: 50mb
13
+ ingest.geoip.downloader.enabled: false