├── .gitignore
├── .travis.yml
├── LICENSE
├── Makefile
├── README.md
├── shard.yml
├── src
├── elasticsearch.cr
├── elasticsearch
│ ├── api.cr
│ └── api
│ │ ├── actions
│ │ ├── abort_benchmark.cr
│ │ ├── benchmark.cr
│ │ ├── bulk.cr
│ │ ├── cat
│ │ │ ├── aliases.cr
│ │ │ ├── allocation.cr
│ │ │ ├── count.cr
│ │ │ ├── fielddata.cr
│ │ │ ├── health.cr
│ │ │ ├── help.cr
│ │ │ ├── indices.cr
│ │ │ ├── master.cr
│ │ │ ├── nodeattrs.cr
│ │ │ ├── nodes.cr
│ │ │ ├── pending_tasks.cr
│ │ │ ├── plugins.cr
│ │ │ ├── recovery.cr
│ │ │ ├── repositories.cr
│ │ │ ├── segments.cr
│ │ │ ├── shards.cr
│ │ │ ├── snapshots.cr
│ │ │ ├── tasks.cr
│ │ │ ├── templates.cr
│ │ │ └── thread_pool.cr
│ │ ├── clear_scroll.cr
│ │ ├── cluster
│ │ │ ├── allocation_explain.cr
│ │ │ ├── get_settings.cr
│ │ │ ├── health.cr
│ │ │ ├── pending_tasks.cr
│ │ │ ├── put_settings.cr
│ │ │ ├── reroute.cr
│ │ │ ├── state.cr
│ │ │ └── stats.cr
│ │ ├── count.cr
│ │ ├── count_percolate.cr
│ │ ├── create.cr
│ │ ├── delete.cr
│ │ ├── delete_by_query.cr
│ │ ├── exists.cr
│ │ ├── explain.cr
│ │ ├── get.cr
│ │ ├── get_source.cr
│ │ ├── index.cr
│ │ ├── indices
│ │ │ ├── analyze.cr
│ │ │ ├── clear_cache.cr
│ │ │ ├── close.cr
│ │ │ ├── create.cr
│ │ │ ├── delete.cr
│ │ │ ├── delete_alias.cr
│ │ │ ├── delete_mapping.cr
│ │ │ ├── delete_template.cr
│ │ │ ├── delete_warmer.cr
│ │ │ ├── exists.cr
│ │ │ ├── exists_alias.cr
│ │ │ ├── exists_template.cr
│ │ │ ├── exists_type.cr
│ │ │ ├── flush.cr
│ │ │ ├── flush_synced.cr
│ │ │ ├── forcemerge.cr
│ │ │ ├── get.cr
│ │ │ ├── get_alias.cr
│ │ │ ├── get_aliases.cr
│ │ │ ├── get_field_mapping.cr
│ │ │ ├── get_mapping.cr
│ │ │ ├── get_settings.cr
│ │ │ ├── get_template.cr
│ │ │ ├── get_warmer.cr
│ │ │ ├── open.cr
│ │ │ ├── optimize.cr
│ │ │ ├── put_alias.cr
│ │ │ ├── put_mapping.cr
│ │ │ ├── put_settings.cr
│ │ │ ├── put_template.cr
│ │ │ ├── put_warmer.cr
│ │ │ ├── recovery.cr
│ │ │ ├── refresh.cr
│ │ │ ├── rollover.cr
│ │ │ ├── seal.cr
│ │ │ ├── segments.cr
│ │ │ ├── shard_stores.cr
│ │ │ ├── shrink.cr
│ │ │ ├── snapshot_index.cr
│ │ │ ├── stats.cr
│ │ │ ├── status.cr
│ │ │ ├── update_aliases.cr
│ │ │ ├── upgrade.cr
│ │ │ └── validate_query.cr
│ │ ├── info.cr
│ │ ├── ingest
│ │ │ ├── delete_pipeline.cr
│ │ │ ├── get_pipeline.cr
│ │ │ ├── put_pipeline.cr
│ │ │ └── simulate.cr
│ │ ├── list_benchmarks.cr
│ │ ├── mget.cr
│ │ ├── mtermvectors.cr
│ │ ├── nodes
│ │ │ ├── hot_threads.cr
│ │ │ ├── info.cr
│ │ │ ├── shutdown.cr
│ │ │ └── stats.cr
│ │ ├── ping.cr
│ │ ├── search.cr
│ │ ├── search_shards.cr
│ │ ├── snapshot
│ │ │ ├── create.cr
│ │ │ ├── create_repository.cr
│ │ │ ├── delete.cr
│ │ │ ├── delete_repository.cr
│ │ │ ├── get.cr
│ │ │ ├── get_repository.cr
│ │ │ ├── restore.cr
│ │ │ ├── status.cr
│ │ │ └── verify_repository.cr
│ │ ├── tasks
│ │ │ ├── cancel.cr
│ │ │ ├── get.cr
│ │ │ └── list.cr
│ │ ├── termvectors.cr
│ │ ├── update.cr
│ │ └── update_by_query.cr
│ │ ├── namespace
│ │ ├── cat.cr
│ │ ├── cluster.cr
│ │ ├── common.cr
│ │ ├── indices.cr
│ │ ├── ingest.cr
│ │ ├── nodes.cr
│ │ ├── snapshot.cr
│ │ └── tasks.cr
│ │ ├── utils.cr
│ │ └── version.cr
└── version.cr
└── test
├── integration
├── actions
│ ├── abort_benchmark_test.cr
│ ├── benchmark_test.cr
│ ├── bulk_test.cr
│ ├── clear_scroll_test.cr
│ ├── count_percolate_test.cr
│ ├── count_test.cr
│ ├── create_test.cr
│ ├── delete_by_query_test.cr
│ ├── delete_test.cr
│ ├── exists_test.cr
│ ├── explain_test.cr
│ ├── get_source_test.cr
│ ├── get_test.cr
│ ├── index_test.cr
│ ├── info_test.cr
│ ├── list_benchmarks_test.cr
│ ├── mget_test.cr
│ ├── mtermvectors_test.cr
│ ├── ping_test.cr
│ ├── search_shards_test.cr
│ ├── search_test.cr
│ ├── termvectors_test.cr
│ ├── update_by_query_test.cr
│ └── update_test.cr
├── cat
│ ├── aliases_test.cr
│ ├── allocation_test.cr
│ ├── count_test.cr
│ ├── fielddata_test.cr
│ ├── health_test.cr
│ ├── help_test.cr
│ ├── indices_test.cr
│ ├── master_test.cr
│ ├── nodeattrs_test.cr
│ ├── nodes_test.cr
│ ├── pending_tasks_test.cr
│ ├── plugins_test.cr
│ ├── recovery_test.cr
│ ├── repositories_test.cr
│ ├── segments_test.cr
│ ├── shards_test.cr
│ ├── snapshots_test.cr
│ ├── tasks_test.cr
│ ├── templates_test.cr
│ └── thread_pool_test.cr
├── cluster
│ ├── allocation_explain_test.cr
│ ├── get_settings_test.cr
│ ├── health_test.cr
│ ├── put_settings_test.cr
│ ├── reroute_test.cr
│ ├── state_test.cr
│ └── stats_test.cr
├── indices
│ ├── analyze_test.cr
│ ├── clear_cache_test.cr
│ ├── close_test.cr
│ ├── create_test.cr
│ ├── delete_alias_test.cr
│ ├── delete_mapping_test.cr
│ ├── delete_template_test.cr
│ ├── delete_test.cr
│ ├── delete_warmer_test.cr
│ ├── exists_alias_test.cr
│ ├── exists_template_test.cr
│ ├── exists_test.cr
│ ├── exists_type_test.cr
│ ├── flush_synced_test.cr
│ ├── flush_test.cr
│ ├── get_alias_test.cr
│ ├── get_aliases_test.cr
│ ├── get_field_mapping_test.cr
│ ├── get_mapping_test.cr
│ ├── get_settings_test.cr
│ ├── get_template_test.cr
│ ├── get_test.cr
│ ├── get_warmer_test.cr
│ ├── open_test.cr
│ ├── optimize_test.cr
│ ├── put_alias_test.cr
│ ├── put_mapping_test.cr
│ ├── put_template_test.cr
│ ├── put_warmer_test.cr
│ ├── recovery_test.cr
│ ├── refresh_test.cr
│ ├── rollover_test.cr
│ ├── seal_test.cr
│ ├── segments_test.cr
│ ├── shard_stores_test.cr
│ ├── shrink_test.cr
│ ├── snapshot_index_test.cr
│ ├── stats_test.cr
│ ├── status_test.cr
│ ├── update_aliases_test.cr
│ ├── upgrade_test.cr
│ └── validate_query_test.cr
├── ingest
│ ├── delete_pipeline_test.cr
│ ├── get_pipeline_test.cr
│ ├── put_pipeline_test.cr
│ └── simulate_test.cr
├── nodes
│ ├── hot_threads_test.cr
│ ├── info_test.cr
│ ├── shutdown_test.cr
│ └── stats_test.cr
├── snapshot
│ ├── create_repository_test.cr
│ ├── create_test.cr
│ ├── delete_repository_test.cr
│ ├── delete_test.cr
│ ├── get_repository_test.cr
│ ├── get_test.cr
│ ├── restore_test.cr
│ ├── status_test.cr
│ └── verify_repository_test.cr
└── tasks
│ └── list_test.cr
└── spec_helper.cr
/.gitignore:
--------------------------------------------------------------------------------
1 | .shards
2 | shard.lock
3 |
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: crystal
2 |
3 | services:
4 | - docker
5 |
6 | before_install:
7 | - docker run -d -p 9250:9200 elasticsearch:5.2
8 |
9 | script:
10 | # wait for elasticsearch to start up
11 | - sleep 10
12 | - make run-test
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 paktek123
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | install:
2 | shards install
3 | run-test:
4 | crystal spec test/integration/actions/*
5 | crystal spec test/integration/cat/*
6 | crystal spec test/integration/cluster/*
7 | crystal spec test/integration/indices/*
8 | crystal spec test/integration/ingest/*
9 | crystal spec test/integration/nodes/*
10 | crystal spec test/integration/snapshot/*
11 | crystal spec test/integration/tasks/*
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
4 |
5 | # Elasticsearch-crystal
6 |
7 | Elasticsearch Library for Crystal Lang. Heavily inspired by Ruby Elasticsearch Library.
8 |
9 | ## Installation
10 |
11 | ```
12 | dependencies:
13 | elasticsearch-crystal:
14 | github: paktek123/elasticsearch-crystal
15 | version: ~> 0.14
16 | ```
17 |
18 | ## Usage
19 |
20 | ```
21 | require "elasticsearch-crystal/elasticsearch/api"
22 |
23 | client = Elasticsearch::API::Client.new({:host => "localhost", :port => 9250})
24 |
25 | # create an index
26 | client.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
27 | client.cat.indices
28 |
29 | # For getting back JSON
30 |
31 | client.cat.indices({:format => "json"}).as(JSON::Any)
32 | ```
33 |
34 | For more example see under the `test` folder
35 |
36 | ## Roadmap
37 |
38 | Right now this although covers most of the Elasticsearch API, still lacks certain functionality. The next features will be driven by community demand.
39 | - Make the repo more 'Crystal' Lang style, it follows ruby conventions or no conventions at all right now
40 | - Code is a bit repetitive in places
41 | - Same functionality as the Ruby Elasticsearch Library
42 |
43 | ## Issues and Bugs
44 |
45 | Although there is a test suite of Elasticsearch there are bound to be many bugs. Please raise an issue with steps to reproduce and any stack traces. Contributions are welcome to fix.
46 |
47 | ## Contribute
48 |
49 | Contributions are welcome!
50 |
51 | - Run a local Elasticsearch on port 9250: `docker run -d -p 9250:9200 elasticsearch:5.2`
52 |
53 | - Run the test suite interested in `crystal spec test/integation/cat/*`
54 |
55 | - Fork the repo and work on your feature in a branch
56 |
57 | - Make a PR
58 |
--------------------------------------------------------------------------------
/shard.yml:
--------------------------------------------------------------------------------
1 | name: elasticsearch-crystal
2 | version: 0.14
3 | authors:
4 | - Neeran Gul
5 |
6 | description: |
7 | Elasticsearch API wrapper for Crystal Lang
8 |
9 | development_dependencies:
10 | spec2:
11 | github: waterlink/spec2.cr
12 |
13 | license: MIT
14 |
--------------------------------------------------------------------------------
/src/elasticsearch.cr:
--------------------------------------------------------------------------------
1 | require "elasticsearch-crystal/elasticsearch/api"
2 |
--------------------------------------------------------------------------------
/src/elasticsearch/api.cr:
--------------------------------------------------------------------------------
1 | require "html"
2 | require "json"
3 |
4 | require "./api/namespace/common"
5 | require "./api/utils"
6 |
7 | require "./api/actions/**"
8 | require "./api/namespace/**"
9 |
10 | module Elasticsearch
11 | module API
12 | class Client < Elasticsearch::API::Common::Client
13 |
14 | include Elasticsearch::API::Common
15 | include Elasticsearch::API::Actions
16 | include Elasticsearch::API::Cluster
17 | include Elasticsearch::API::Nodes
18 | include Elasticsearch::API::Indices
19 | include Elasticsearch::API::Ingest
20 | include Elasticsearch::API::Snapshot
21 | include Elasticsearch::API::Tasks
22 | include Elasticsearch::API::Cat
23 |
24 | property :settings
25 |
26 | def initialize(@settings : Hash(Symbol, String | Int32))
27 | end
28 |
29 | # The serializer class
30 | #
31 | def serializer
32 | @settings[:serializer] || Elasticsearch::API::Common::Constants::DEFAULT_SERIALIZER
33 | end
34 |
35 | def cat
36 | @cat ||= Elasticsearch::API::Cat::CatClient.new @settings
37 | end
38 |
39 | def cluster
40 | @cluster ||= Elasticsearch::API::Cluster::ClusterClient.new @settings
41 | end
42 |
43 | def indices
44 | @indices ||= Elasticsearch::API::Indices::IndicesClient.new @settings
45 | end
46 |
47 | def ingest
48 | @ingest ||= Elasticsearch::API::Ingest::IngestClient.new @settings
49 | end
50 |
51 | def nodes
52 | @nodes ||= Elasticsearch::API::Nodes::NodesClient.new @settings
53 | end
54 |
55 | def snapshot
56 | @snapshot ||= Elasticsearch::API::Snapshot::SnapshotClient.new @settings
57 | end
58 |
59 | def tasks
60 | @tasks ||= Elasticsearch::API::Tasks::TasksClient.new @settings
61 | end
62 | end
63 | end
64 | end
65 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/abort_benchmark.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Abort a running benchmark
6 | #
7 | # @example
8 | #
9 | # client.abort_benchmark name: 'my_benchmark'
10 | #
11 | # @option arguments [String] :name A benchmark name
12 | #
13 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html
14 | #
15 | def abort_benchmark(arguments={} of Symbol => String)
16 | method = "POST"
17 | path = "_bench/abort/#{arguments[:name]}"
18 | params = {} of String => String
19 | body = nil
20 |
21 | perform_request(method, path, params, body).body
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/benchmark.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Run a single query, or a set of queries, and return statistics on their performance
6 | #
7 | # @example Return statistics for a single query
8 | #
9 | # client.benchmark body: {
10 | # name: 'my_benchmark',
11 | # competitors: [
12 | # {
13 | # name: 'query_1',
14 | # requests: [
15 | # { query: { match: { _all: 'a*' } } }
16 | # ]
17 | # }
18 | # ]
19 | # }
20 | #
21 | # @example Return statistics for a set of "competing" queries
22 | #
23 | # client.benchmark body: {
24 | # name: 'my_benchmark',
25 | # competitors: [
26 | # {
27 | # name: 'query_a',
28 | # requests: [
29 | # { query: { match: { _all: 'a*' } } }
30 | # ]
31 | # },
32 | # {
33 | # name: 'query_b',
34 | # requests: [
35 | # { query: { match: { _all: 'b*' } } }
36 | # ]
37 | # }
38 | # ]
39 | # }
40 | #
41 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
42 | # to perform the operation on all indices
43 | # @option arguments [String] :type The name of the document type
44 | # @option arguments [Hash] :body The search definition using the Query DSL
45 | # @option arguments [Boolean] :verbose Specify whether to return verbose statistics about each iteration
46 | # (default: false)
47 | #
48 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html
49 | #
50 | def benchmark(arguments={} of Symbol => String)
51 | valid_params = [
52 | :verbose ]
53 | method = "PUT"
54 | path = "_bench"
55 | params = Utils.__validate_and_extract_params arguments, valid_params
56 | body = arguments[:body]
57 |
58 | perform_request(method, path, params, body).body
59 | end
60 | end
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/fielddata.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Return information about field data usage across the cluster
7 | #
8 | # @example Return the total size of field data
9 | #
10 | # client.cat.fielddata
11 | #
12 | # @example Return both the total size and size for specific fields
13 | #
14 | # client.cat.fielddata fields: 'title,body'
15 | #
16 | # @option arguments [List] :fields A comma-separated list of fields to include in the output
17 | # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
18 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
19 | # (default: false)
20 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
21 | # @option arguments [List] :h Comma-separated list of column names to display
22 | # @option arguments [Boolean] :help Return help information
23 | # @option arguments [Boolean] :v Verbose mode. Display column headers
24 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
25 | #
26 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-fielddata.html
27 | #
28 | def fielddata(arguments={} of Symbol => String)
29 | valid_params = [
30 | :bytes,
31 | :local,
32 | :master_timeout,
33 | :h,
34 | :help,
35 | :v,
36 | :s,
37 | :fields ]
38 |
39 | fields = arguments.delete(:fields) || ""
40 |
41 | method = "GET"
42 | path = Utils.__pathify "_cat/fielddata", Utils.__listify(fields.as(String))
43 | arguments = Utils.__sort_booleans(arguments)
44 | params = Utils.__validate_and_extract_params arguments, valid_params
45 | body = nil
46 |
47 | perform_request(method, path, params, body).body
48 | end
49 | end
50 | end
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/health.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Display a terse version of the {Elasticsearch::API::Cluster::Actions#health} API output
7 | #
8 | # @example Display cluster health
9 | #
10 | # puts client.cat.health
11 | #
12 | # @example Display header names in the output
13 | #
14 | # puts client.cat.health v: true
15 | #
16 | # @example Return the information as Ruby objects
17 | #
18 | # client.cat.health format: 'json'
19 | #
20 | # @option arguments [Boolean] :ts Whether to display timestamp information
21 | # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
22 | # @option arguments [Boolean] :v Display column headers as part of the output
23 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
24 | # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
25 | # @option arguments [Boolean] :help Return information about headers
26 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
27 | # (default: false)
28 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
29 | #
30 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-health.html
31 | #
32 | def health(arguments={} of Symbol => String)
33 | valid_params = [
34 | :local,
35 | :master_timeout,
36 | :h,
37 | :help,
38 | :ts,
39 | :v,
40 | :s ]
41 |
42 | method = "GET"
43 | path = "_cat/health"
44 | arguments = Utils.__sort_booleans(arguments)
45 | params = Utils.__validate_and_extract_params arguments, valid_params
46 | params[:h] = Utils.__listify(params[:h].as(String)) if params.has_key?(:h)
47 | body = nil
48 |
49 | perform_request(method, path, params, body).body
50 | end
51 | end
52 | end
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/help.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Help information for the Cat API
7 | #
8 | # @option arguments [Boolean] :help Return help information
9 | #
10 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html
11 | #
12 | def help(arguments={} of Symbol => String)
13 | valid_params = [
14 | :help ]
15 | method = "GET"
16 | path = "_cat"
17 | params = Utils.__validate_and_extract_params arguments, valid_params
18 | body = nil
19 |
20 | perform_request(method, path, params, body).body
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/master.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Display basic information about the master node
7 | #
8 | # @example
9 | #
10 | # puts client.cat.master
11 | #
12 | # @example Display header names in the output
13 | #
14 | # puts client.cat.master v: true
15 | #
16 | # @example Return the information as Ruby objects
17 | #
18 | # client.cat.master format: 'json'
19 | #
20 | # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
21 | # @option arguments [Boolean] :v Display column headers as part of the output
22 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
23 | # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
24 | # @option arguments [Boolean] :help Return information about headers
25 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
26 | # (default: false)
27 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
28 | #
29 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-master.html
30 | #
31 | def master(arguments={} of Symbol => String)
32 | valid_params = [
33 | :local,
34 | :master_timeout,
35 | :h,
36 | :help,
37 | :v,
38 | :s ]
39 |
40 | method = "GET"
41 | path = "_cat/master"
42 | params = Utils.__validate_and_extract_params arguments, valid_params
43 | body = nil
44 |
45 | perform_request(method, path, params, body).body
46 | end
47 | end
48 | end
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/nodeattrs.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Display custom node attributes
7 | #
8 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
9 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
10 | # @option arguments [List] :h Comma-separated list of column names to display
11 | # @option arguments [Boolean] :help Return help information
12 | # @option arguments [Boolean] :v Verbose mode. Display column headers
13 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
14 | #
15 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html
16 | #
17 | def nodeattrs(arguments={} of Symbol => String)
18 | valid_params = [
19 | :local,
20 | :master_timeout,
21 | :h,
22 | :help,
23 | :v,
24 | :s ]
25 | method = "GET"
26 | path = "_cat/nodeattrs"
27 | params = Utils.__validate_and_extract_params arguments, valid_params
28 | body = nil
29 |
30 | perform_request(method, path, params, body).body
31 | end
32 | end
33 | end
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/pending_tasks.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Display the information from the {Cluster::Actions#pending_tasks} API in a tabular format
7 | #
8 | # @example
9 | #
10 | # puts client.cat.pending_tasks
11 | #
12 | # @example Display header names in the output
13 | #
14 | # puts client.cat.pending_tasks v: true
15 | #
16 | # @example Return the information as Ruby objects
17 | #
18 | # client.cat.pending_tasks format: 'json'
19 | #
20 | # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
21 | # @option arguments [Boolean] :v Display column headers as part of the output
22 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
23 | # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
24 | # @option arguments [Boolean] :help Return information about headers
25 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
26 | # (default: false)
27 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
28 | #
29 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-pending-tasks.html
30 | #
31 | def pending_tasks(arguments={} of Symbol => String)
32 | valid_params = [
33 | :local,
34 | :master_timeout,
35 | :h,
36 | :help,
37 | :v,
38 | :s ]
39 |
40 | method = "GET"
41 | path = "_cat/pending_tasks"
42 | arguments = Utils.__sort_booleans(arguments)
43 | params = Utils.__validate_and_extract_params arguments, valid_params
44 | params[:h] = Utils.__listify(params[:h].as(String)) if params.has_key?(:h)
45 | body = nil
46 |
47 | perform_request(method, path, params, body).body
48 | end
49 | end
50 | end
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/plugins.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Return information about installed plugins
7 | #
8 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
9 | # (default: false)
10 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
11 | # @option arguments [List] :h Comma-separated list of column names to display
12 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
13 | # @option arguments [Boolean] :help Return help information
14 | # @option arguments [Boolean] :v Verbose mode. Display column headers
15 | #
16 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html
17 | #
18 | def plugins(arguments={} of Symbol => String)
19 | valid_params = [
20 | :local,
21 | :master_timeout,
22 | :h,
23 | :help,
24 | :v,
25 | :s ]
26 | method = "GET"
27 | path = "_cat/plugins"
28 | params = Utils.__validate_and_extract_params arguments, valid_params
29 | body = nil
30 |
31 | perform_request(method, path, params, body).body
32 | end
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/repositories.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Shows all repositories registered in a cluster
7 | #
8 | # @example Return list of repositories
9 | #
10 | # client.cat.repositories
11 | #
12 | # @example Return only id for each repository
13 | #
14 | # client.cat.repositories h: 'id'
15 | #
16 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
17 | # @option arguments [List] :h Comma-separated list of column names to display
18 | # @option arguments [Boolean] :help Return help information
19 | # @option arguments [Boolean] :v Verbose mode. Display column headers
20 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
21 | #
22 | # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-repositories.html
23 | #
24 | def repositories(arguments={} of Symbol => String)
25 | valid_params = [
26 | :master_timeout,
27 | :h,
28 | :help,
29 | :v,
30 | :s ]
31 |
32 | method = "GET"
33 | path = "_cat/repositories"
34 | params = Utils.__validate_and_extract_params arguments, valid_params
35 | body = nil
36 |
37 | perform_request(method, path, params, body).body
38 | end
39 | end
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/segments.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Display information about the segments in the shards of an index
7 | #
8 | # @example Display information for all indices
9 | #
10 | # puts client.cat.segments
11 | #
12 | # @option arguments [List] :index A comma-separated list of index names to limit the returned information
13 | # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
14 | # @option arguments [List] :h Comma-separated list of column names to display
15 | # @option arguments [Boolean] :help Return help information
16 | # @option arguments [Boolean] :v Verbose mode. Display column headers
17 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
18 | #
19 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-segments.html
20 | #
21 | def segments(arguments={} of Symbol => String)
22 | valid_params = [
23 | :bytes,
24 | :index,
25 | :h,
26 | :help,
27 | :v,
28 | :s ]
29 | method = "GET"
30 | path = "_cat/segments"
31 | params = Utils.__validate_and_extract_params arguments, valid_params
32 | body = nil
33 |
34 | perform_request(method, path, params, body).body
35 | end
36 | end
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/snapshots.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Shows all snapshots that belong to a specific repository
7 | #
8 | # @example Return snapshots for 'my_repository'
9 | #
10 | # client.cat.snapshots repository: 'my_repository'
11 | #
12 | # @example Return id, status and start_epoch for 'my_repository'
13 | #
14 | # client.cat.snapshots repository: 'my_repository', h: 'id,status,start_epoch'
15 | #
16 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
17 | # @option arguments [List] :h Comma-separated list of column names to display
18 | # @option arguments [Boolean] :help Return help information
19 | # @option arguments [Boolean] :v Verbose mode. Display column headers
20 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
21 | #
22 | # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html
23 | #
24 | def snapshots(arguments={} of Symbol => String)
25 | if !arguments.has_key?(:repository)
26 | raise ArgumentError.new("Required argument 'repository' missing")
27 | end
28 |
29 | valid_params = [
30 | :master_timeout,
31 | :h,
32 | :help,
33 | :v,
34 | :s ]
35 |
36 | repository = arguments.delete(:repository) || ""
37 |
38 | method = "GET"
39 | arguments = Utils.__sort_booleans(arguments)
40 | path = Utils.__pathify "_cat/snapshots", Utils.__escape(repository.as(String))
41 | params = Utils.__validate_and_extract_params arguments, valid_params
42 | body = nil
43 |
44 | perform_request(method, path, params, body).body
45 | end
46 | end
47 | end
48 | end
49 | end
50 |
51 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/tasks.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Return currently running tasks
7 | #
8 | # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
9 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
10 | # @option arguments [List] :actions A comma-separated list of actions that should be returned. Leave empty to return all.
11 | # @option arguments [Boolean] :detailed Return detailed task information (default: false)
12 | # @option arguments [String] :parent_node Return tasks with specified parent node.
13 | # @option arguments [Number] :parent_task Return tasks with specified parent task id. Set to -1 to return all.
14 | # @option arguments [List] :h Comma-separated list of column names to display
15 | # @option arguments [Boolean] :help Return help information
16 | # @option arguments [Boolean] :v Verbose mode. Display column headers
17 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
18 | #
19 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
20 | #
21 | def tasks(arguments={} of Symbol => String)
22 | valid_params = [
23 | :format,
24 | :node_id,
25 | :actions,
26 | :detailed,
27 | :parent_node,
28 | :parent_task,
29 | :h,
30 | :help,
31 | :v,
32 | :s ]
33 | method = "GET"
34 | path = "_cat/tasks"
35 | params = Utils.__validate_and_extract_params arguments, valid_params
36 | body = nil
37 |
38 | perform_request(method, path, params, body).body
39 | end
40 | end
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cat/templates.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions
5 |
6 | # Returns information about existing templates
7 | #
8 | # @option arguments [String] :name A pattern that returned template names must match
9 | # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
10 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
11 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
12 | # @option arguments [List] :h Comma-separated list of column names to display
13 | # @option arguments [Boolean] :help Return help information
14 | # @option arguments [Boolean] :v Verbose mode. Display column headers
15 | # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
16 | #
17 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html
18 | #
19 | def templates(arguments={} of Symbol => String)
20 | valid_params = [
21 | :name,
22 | :format,
23 | :local,
24 | :master_timeout,
25 | :h,
26 | :help,
27 | :v,
28 | :s ]
29 | method = "GET"
30 | path = "_cat/templates"
31 | params = Utils.__validate_and_extract_params arguments, valid_params
32 | body = nil
33 |
34 | perform_request(method, path, params, body).body
35 | end
36 | end
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/clear_scroll.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Abort a particular scroll search and clear all the resources associated with it.
6 | #
7 | # @option arguments [List] :scroll_id A comma-separated list of scroll IDs to clear;
8 | # use `_all` clear all scroll search contexts
9 | #
10 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html#clear-scroll
11 | #
12 | def clear_scroll(arguments={} of Symbol => String)
13 | if !arguments.has_key?(:scroll_id)
14 | raise ArgumentError.new("Required argument 'scroll_id' missing")
15 | end
16 |
17 | scroll_id = arguments.delete(:scroll_id)
18 |
19 | method = "DELETE"
20 | path = Utils.__pathify "_search/scroll", Utils.__listify(scroll_id.as(String))
21 | params = {} of String => String
22 | body = arguments[:body]
23 |
24 | perform_request(method, path, params, body).body
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cluster/allocation_explain.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions
5 |
6 | # Return the information about why a shard is or isn't allocated
7 | #
8 | # @option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard'
9 | # @option arguments [Boolean] :include_yes_decisions Return 'YES' decisions in explanation (default: false)
10 | # @option arguments [Boolean] :include_disk_info Return information about disk usage and shard sizes
11 | # (default: false)
12 | #
13 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html
14 | #
15 | def allocation_explain(arguments={} of Symbol => String)
16 | valid_params = [
17 | :include_yes_decisions,
18 | :include_disk_info ]
19 | method = "GET"
20 | path = "_cluster/allocation/explain"
21 | params = Utils.__validate_and_extract_params arguments, valid_params
22 | body = arguments[:body]
23 |
24 | perform_request(method, path, params, body).body
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cluster/get_settings.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions
5 |
6 | # Get the cluster settings (previously set with {Cluster::Actions#put_settings})
7 | #
8 | # @example Get cluster settings
9 | #
10 | # client.cluster.get_settings
11 | #
12 | # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
13 | # @option arguments [Boolean] :include_defaults Whether to return all default clusters setting
14 | # (default: false)
15 | #
16 | # @see http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
17 | #
18 | def get_settings(arguments={} of Symbol => String)
19 | valid_params = [
20 | :flat_settings,
21 | :include_defaults
22 | ]
23 |
24 | method = "GET"
25 | path = "_cluster/settings"
26 | params = Utils.__validate_and_extract_params arguments, valid_params
27 | body = nil
28 |
29 | perform_request(method, path, params, body).body
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cluster/pending_tasks.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions
5 |
6 | # Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard)
7 | # which have not yet been executed and are queued up.
8 | #
9 | # @example Get a list of currently queued up tasks in the cluster
10 | #
11 | # client.cluster.pending_tasks
12 | #
13 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
14 | # (default: false)
15 | # @option arguments [Time] :master_timeout Specify timeout for connection to master
16 | #
17 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cluster-pending.html
18 | #
19 | def pending_tasks(arguments={} of Symbol => String)
20 | valid_params = [
21 | :local,
22 | :master_timeout ]
23 | method = "GET"
24 | path = "_cluster/pending_tasks"
25 | params = Utils.__validate_and_extract_params arguments, valid_params
26 | body = nil
27 |
28 | perform_request(method, path, params, body).body
29 | end
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cluster/put_settings.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions
5 |
6 | # Update cluster settings.
7 | #
8 | # @example Disable shard allocation in the cluster until restart
9 | #
10 | # client.cluster.put_settings body: { transient: { 'cluster.routing.allocation.disable_allocation' => true } }
11 | #
12 | # @option arguments [Hash] :body The settings to be updated. Can be either `transient` or `persistent`
13 | # (survives cluster restart).
14 | #
15 | # @see http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
16 | #
17 | def put_settings(arguments={} of Symbol => String)
18 | valid_params = [ :flat_settings ]
19 |
20 | method = "PUT"
21 | path = "_cluster/settings"
22 | params = Utils.__validate_and_extract_params arguments, valid_params
23 | body = arguments[:body] || ""
24 |
25 | perform_request(method, path, params, body).body
26 | end
27 | end
28 | end
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/cluster/stats.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions
5 |
6 | # Returns statistical information about the cluster
7 | #
8 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
9 | # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
10 | # @option arguments [Boolean] :human Whether to return time and byte values in human-readable format.
11 | # @option arguments [Time] :timeout Explicit operation timeout
12 | #
13 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html
14 | #
15 | def stats(arguments={} of Symbol => String)
16 | valid_params = [
17 | :flat_settings,
18 | :human,
19 | :timeout ]
20 | method = "GET"
21 | path = "_cluster/stats"
22 | params = Utils.__validate_and_extract_params arguments, valid_params
23 | body = nil
24 |
25 | perform_request(method, path, params, body).body
26 | end
27 | end
28 | end
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/create.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Create a document.
6 | #
7 | # Enforce the _create_ operation when indexing a document --
8 | # the operation will return an error when the document already exists.
9 | #
10 | # @example Create a document
11 | #
12 | # client.create index: 'myindex',
13 | # type: 'mytype',
14 | # id: '1',
15 | # body: {
16 | # title: 'Test 1',
17 | # tags: ['y', 'z'],
18 | # published: true,
19 | # published_at: Time.now.utc.iso8601,
20 | # counter: 1
21 | # }
22 | #
23 | # @option (see Actions#index)
24 | #
25 | # (The `:op_type` argument is ignored.)
26 | #
27 | # @see http://elasticsearch.org/guide/reference/api/index_/
28 | #
29 | def create(arguments={} of Symbol => String)
30 | index arguments
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/delete.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Delete an index, list of indices, or all indices in the cluster.
7 | #
8 | # @example Delete an index
9 | #
10 | # client.indices.delete index: 'foo'
11 | #
12 | # @example Delete a list of indices
13 | #
14 | # client.indices.delete index: ['foo', 'bar']
15 | # client.indices.delete index: 'foo,bar'
16 | #
17 | #
18 | # @example Delete a list of indices matching wildcard expression
19 | #
20 | # client.indices.delete index: 'foo*'
21 | #
22 | # @example Delete all indices
23 | #
24 | # client.indices.delete index: '_all'
25 | #
26 | # @option arguments [List] :index A comma-separated list of indices to delete;
27 | # use `_all` to delete all indices
28 | # @option arguments [Time] :timeout Explicit operation timeout
29 | #
30 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/
31 | #
32 | def delete(arguments={} of Symbol => String)
33 | valid_params = [ :timeout ]
34 |
35 | method = "DELETE"
36 | path = Utils.__pathify Utils.__listify(arguments[:index])
37 |
38 | params = Utils.__validate_and_extract_params arguments, valid_params
39 | body = nil
40 |
41 | perform_request(method, path, params, body).body
42 |
43 | end
44 | end
45 | end
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/delete_alias.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Delete a single index alias.
7 | #
8 | # @example Delete an alias
9 | #
10 | # client.indices.delete_alias index: 'foo', name: 'bar'
11 | #
12 | # See the {Indices::Actions#update_aliases} for performing operations with index aliases in bulk.
13 | #
14 | # @option arguments [String] :index The name of the index with an alias (*Required*)
15 | # @option arguments [String] :name The name of the alias to be deleted (*Required*)
16 | # @option arguments [Time] :timeout Explicit timestamp for the document
17 | #
18 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
19 | #
20 | def delete_alias(arguments={} of Symbol => String)
21 | if !arguments.has_key?(:index) || !arguments.has_key?(:name)
22 | raise ArgumentError.new("Required argument 'index' and 'name' missing")
23 | end
24 | valid_params = [ :timeout ]
25 |
26 | method = "DELETE"
27 | path = Utils.__pathify Utils.__escape(arguments[:index]), "_alias", Utils.__escape(arguments[:name])
28 |
29 | params = Utils.__validate_and_extract_params arguments, valid_params
30 | body = nil
31 |
32 | perform_request(method, path, params, body).body
33 | end
34 | end
35 | end
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/delete_mapping.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Delete all documents and mapping for a specific document type.
7 | #
8 | # @option arguments [List] :index A comma-separated list of index names; use `_all` for all indices (*Required*)
9 | # @option arguments [String] :type The name of the document type to delete (*Required*)
10 | #
11 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping/
12 | #
13 | def delete_mapping(arguments={} of Symbol => String)
14 | if !arguments.has_key?(:index) || !arguments.has_key?(:type)
15 | raise ArgumentError.new("Required argument 'index' and 'type' missing")
16 | end
17 | method = "DELETE"
18 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), Utils.__escape(arguments[:type].as(String))
19 | params = {} of String => String
20 | body = nil
21 |
22 | perform_request(method, path, params, body).body
23 | end
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/delete_template.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Delete an index template.
7 | #
8 | # @example Delete a template named _mytemplate_
9 | #
10 | # client.indices.delete_template name: 'mytemplate'
11 | #
12 | # @example Delete all templates
13 | #
14 | # client.indices.delete_template name: '*'
15 | #
16 | # @option arguments [String] :name The name of the template (*Required*)
17 | # @option arguments [Time] :timeout Explicit operation timeout
18 | #
19 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
20 | #
21 | def delete_template(arguments={} of Symbol => String)
22 | if !arguments.has_key?(:name)
23 | raise ArgumentError.new("Required argument 'name' missing")
24 | end
25 | valid_params = [ :timeout ]
26 |
27 | method = "DELETE"
28 | path = Utils.__pathify "_template", Utils.__escape(arguments[:name].as(String))
29 |
30 | body = nil
31 |
32 | perform_request(method, path, {} of String => String, body).body
33 | end
34 | end
35 | end
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/delete_warmer.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Delete one or more warmers for a list of indices.
7 | #
8 | # @example Delete a warmer named _mywarmer_ for index named _myindex_
9 | #
10 | # client.indices.delete_warmer index: 'myindex', name: 'mywarmer'
11 | #
12 | # @option arguments [List] :index A comma-separated list of index names to register warmer for; use `_all`
13 | # or empty string to perform the operation on all indices (*Required*)
14 | # @option arguments [String] :name The name of the warmer (supports wildcards); leave empty to delete all warmers
15 | # @option arguments [List] :type A comma-separated list of document types to register warmer for; use `_all`
16 | # or empty string to perform the operation on all types
17 | #
18 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
19 | #
20 | def delete_warmer(arguments={} of Symbol => String)
21 | if !arguments.has_key?(:index)
22 | raise ArgumentError.new("Required argument 'index' missing")
23 | end
24 | method = "DELETE"
25 | path = Utils.__pathify Utils.__listify(arguments[:index]), "_warmer", Utils.__listify(arguments[:name])
26 | params = {} of String => String
27 | body = nil
28 |
29 | perform_request(method, path, params, body).body
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/exists_template.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Return true if the specified index template exists, false otherwise.
7 | #
8 | # client.indices.exists_template? name: 'mytemplate'
9 | #
10 | # @option arguments [String] :name The name of the template (*Required*)
11 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
12 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
13 | #
14 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-templates.html
15 | #
16 | def exists_template(arguments={} of Symbol => String)
17 | if !arguments.has_key?(:name)
18 | raise ArgumentError.new("Required argument 'name' missing")
19 | end
20 | valid_params = [ :local, :master_timeout ]
21 |
22 | method = "HEAD"
23 | path = Utils.__pathify "_template", Utils.__escape(arguments[:name].as(String))
24 |
25 | params = Utils.__validate_and_extract_params arguments, valid_params
26 | body = nil
27 |
28 | perform_request(method, path, params, body).status == 200 ? true : false
29 |
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/flush_synced.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices
7 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
8 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
9 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
10 | #
11 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html
12 | #
13 | def flush_synced(arguments={} of Symbol => String)
14 | valid_params = [
15 | :ignore_unavailable,
16 | :allow_no_indices,
17 | :expand_wildcards
18 | ]
19 |
20 | method = "POST"
21 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_flush/synced"
22 |
23 | params = Utils.__validate_and_extract_params arguments, valid_params
24 | body = nil
25 |
26 | perform_request(method, path, params, body).body
27 |
28 | end
29 | end
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/get_aliases.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Get a list of all aliases, or aliases for a specific index.
7 | #
8 | # @example Get a list of all aliases
9 | #
10 | # client.indices.get_aliases
11 | #
12 | # @option arguments [List] :index A comma-separated list of index names to filter aliases
13 | # @option arguments [List] :name A comma-separated list of alias names to filter
14 | # @option arguments [Time] :timeout Explicit timestamp for the document
15 | # @option arguments [Boolean] :local Return local information,
16 | # do not retrieve the state from master node (default: false)
17 | #
18 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html
19 | #
20 | def get_aliases(arguments={} of Symbol => String)
21 | valid_params = [ :timeout, :local ]
22 |
23 | method = "GET"
24 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_aliases", Utils.__listify(arguments[:name].as(String))
25 |
26 | params = Utils.__validate_and_extract_params arguments, valid_params
27 | body = nil
28 |
29 | perform_request(method, path, params, body).body
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/get_template.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Get a single index template.
7 | #
8 | # @example Get all templates
9 | #
10 | # client.indices.get_template
11 | #
12 | # @example Get a template named _mytemplate_
13 | #
14 | # client.indices.get_template name: 'mytemplate'
15 | #
16 | # @note Use the {Cluster::Actions#state} API to get a list of all templates.
17 | #
18 | # @option arguments [String] :name The name of the template (supports wildcards)
19 | # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
20 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
21 | # (default: false)
22 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
23 | #
24 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
25 | #
26 | def get_template(arguments={} of Symbol => String)
27 | valid_params = [ :flat_settings, :local, :master_timeout ]
28 |
29 | method = "GET"
30 | path = Utils.__pathify "_template", Utils.__escape(arguments[:name].as(String))
31 |
32 | params = Utils.__validate_and_extract_params arguments, valid_params
33 |
34 | if arguments.has_key? :body
35 | body = arguments.delete(:body)
36 | else
37 | body = nil
38 | end
39 |
40 | perform_request(method, path, params, body).body
41 | end
42 | end
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/open.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Open a previously closed index (see the {Indices::Actions#close} API).
7 | #
8 | # @example Open index named _myindex_
9 | #
10 | # client.indices.open index: 'myindex'
11 | #
12 | # @option arguments [List] :index A comma separated list of indices to perform the operation on
13 | # (*Required*)
14 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
15 | # no concrete indices. (This includes `_all` string or when no
16 | # indices have been specified)
17 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
18 | # are open, closed or both. (options: open, closed)
19 | # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
20 | # `missing` ones (options: none, missing) @until 1.0
21 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
22 | # unavailable (missing, closed, etc)
23 | # @option arguments [Time] :timeout Explicit operation timeout
24 | #
25 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
26 | #
27 | def open(arguments={} of Symbol => String)
28 | if !arguments.has_key?(:index)
29 | raise ArgumentError.new("Required argument 'index' missing")
30 | end
31 |
32 | valid_params = [
33 | :ignore_indices,
34 | :ignore_unavailable,
35 | :allow_no_indices,
36 | :expand_wildcards,
37 | :timeout
38 | ]
39 |
40 | method = "POST"
41 | path = Utils.__pathify Utils.__escape(arguments[:index].as(String)), "_open"
42 |
43 | params = Utils.__validate_and_extract_params arguments, valid_params
44 | body = nil
45 |
46 | perform_request(method, path, params, body).body
47 | end
48 | end
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/put_alias.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Create or update a single index alias.
7 | #
8 | # @example Create an alias for current month
9 | #
10 | # client.indices.put_alias index: 'logs-2013-06', name: 'current-month'
11 | #
12 | # @example Create an alias for multiple indices
13 | #
14 | # client.indices.put_alias index: 'logs-2013-06', name: 'year-2013'
15 | # client.indices.put_alias index: 'logs-2013-05', name: 'year-2013'
16 | #
17 | # See the {Indices::Actions#update_aliases} for performing operations with index aliases in bulk.
18 | #
19 | # @option arguments [String] :index The name of the index with an alias
20 | # @option arguments [String] :name The name of the alias to be created or updated
21 | # @option arguments [Hash] :body The settings for the alias, such as `routing` or `filter`
22 | # @option arguments [Time] :timeout Explicit timestamp for the document
23 | #
24 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
25 | #
26 | def put_alias(arguments={} of Symbol => String)
27 | if !arguments.has_key?(:name)
28 | raise ArgumentError.new("Required argument 'name' missing")
29 | end
30 | valid_params = [ :timeout ]
31 |
32 | method = "PUT"
33 |
34 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_alias", Utils.__escape(arguments[:name].as(String))
35 |
36 | params = Utils.__validate_and_extract_params arguments, valid_params
37 | if arguments.has_key? :body
38 | body = arguments[:body]
39 | else
40 | body = nil
41 | end
42 |
43 | perform_request(method, path, params, body).body
44 | end
45 | end
46 | end
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/put_template.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Create or update an index template.
7 | #
8 | # @example Create a template for all indices starting with `logs-`
9 | #
10 | # client.indices.put_template name: 'foo',
11 | # body: { template: 'logs-*', settings: { 'index.number_of_shards' => 1 } }
12 | #
13 | # @option arguments [String] :name The name of the template (*Required*)
14 | # @option arguments [Hash] :body The template definition (*Required*)
15 | # @option arguments [Boolean] :create Whether the index template should only be added for a new one, # or can also replace an existing one (default: false)
16 | # @option arguments [Number] :order The order for this template when merging multiple matching ones
17 | # (higher numbers are merged later, overriding the lower numbers)
18 | # @option arguments [Time] :timeout Explicit operation timeout
19 | # @option arguments [Time] :master_timeout Specify timeout for connection to master
20 | # @option arguments [Boolean] :flat_settings Return settings in flat format (default: false)
21 | #
22 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
23 | #
24 | def put_template(arguments={} of Symbol => String)
25 | if !arguments.has_key?(:name) || !arguments.has_key?(:body)
26 | raise ArgumentError.new("Required argument 'name' or 'body' missing")
27 | end
28 | valid_params = [ :create, :order, :timeout ]
29 |
30 | if arguments.has_key? :create
31 | arguments[:create] = ""
32 | end
33 |
34 | if arguments.has_key? :flat_settings
35 | arguments[:flat_settings] = ""
36 | end
37 |
38 | method = "PUT"
39 | path = Utils.__pathify "_template", Utils.__escape(arguments[:name].as(String))
40 | body = arguments[:body]
41 |
42 | perform_request(method, path, {} of String => String, body).body
43 | end
44 | end
45 | end
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/recovery.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Return information about shard recovery for one or more indices
7 | #
8 | # @example Get recovery information for a single index
9 | #
10 | # client.indices.recovery index: 'foo'
11 | #
12 | # @example Get detailed recovery information for multiple indices
13 | #
14 | # client.indices.recovery index: ['foo', 'bar'], detailed: true
15 | #
16 | # @example Get recovery information for all indices
17 | #
18 | # client.indices.recovery
19 | #
20 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
21 | # @option arguments [Boolean] :detailed Whether to display detailed information about shard recovery
22 | # @option arguments [Boolean] :active_only Display only those recoveries that are currently on-going
23 | # @option arguments [Boolean] :human Whether to return time and byte values in human readable format
24 | #
25 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-recovery.html
26 | #
27 | def recovery(arguments={} of Symbol => String)
28 | valid_params = [
29 | :detailed,
30 | :active_only,
31 | :human ]
32 | method = "GET"
33 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_recovery"
34 | params = Utils.__validate_and_extract_params arguments, valid_params
35 | body = nil
36 |
37 | perform_request(method, path, params, body).body
38 | end
39 | end
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/rollover.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # The rollover index API rolls an alias over to a new index when the existing index
7 | # is considered to be too large or too old
8 | #
9 | # @option arguments [String] :alias The name of the alias to rollover (*Required*)
10 | # @option arguments [String] :new_index The name of the rollover index
11 | # @option arguments [Hash] :body The conditions that needs to be met for executing rollover
12 | # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
13 | # @option arguments [Time] :timeout Explicit operation timeout
14 | # @option arguments [Time] :master_timeout Specify timeout for connection to master
15 | #
16 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html
17 | #
18 | def rollover(arguments={} of Symbol => String)
19 | if !arguments.has_key?(:alias) || !arguments.has_key?(:body)
20 | raise ArgumentError.new("Required argument 'alias' or 'body' missing")
21 | end
22 |
23 | valid_params = [
24 | :wait_for_active_shards,
25 | :timeout,
26 | :master_timeout ]
27 |
28 | arguments = arguments.clone
29 |
30 | source = arguments.delete(:alias)
31 | target = arguments.delete(:new_index) || ""
32 |
33 | method = "POST"
34 | path = Utils.__pathify source.as(String), "_rollover", target
35 | params = Utils.__validate_and_extract_params arguments, valid_params
36 | body = arguments[:body]
37 |
38 | perform_request(method, path, params, body).body
39 | end
40 | end
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/seal.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # "Seal" and index or indices for faster recovery
7 | #
8 | # @option arguments [List] :index A comma-separated list of index names;
9 | # use `_all` or empty string for all indices
10 | #
11 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-seal.html
12 | #
13 | def seal(arguments={} of Symbol => String)
14 | method = "POST"
15 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_seal"
16 | params = {} of String => String
17 | body = nil
18 |
19 | perform_request(method, path, params, body).body
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/segments.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Return information about segments for one or more indices.
7 | #
8 | # The response contains information about segment size, number of documents, deleted documents, etc.
9 | # See also {Indices::Actions#optimize}.
10 | #
11 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
12 | # to perform the operation on all indices
13 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression
14 | # resolves into no concrete indices. (This includes `_all`
15 | # string or when no indices have been specified)
16 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
17 | # that are open, closed or both. (options: open, closed)
18 | # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
19 | # `missing` ones (options: none, missing) @until 1.0
20 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
21 | # unavailable (missing, closed, etc)
22 | # @option arguments [Boolean] :verbose Whether to include detailed memory usage by Lucene (default: false)
23 | #
24 | # @see http://elasticsearch.org/guide/reference/api/admin-indices-segments/
25 | #
26 | def segments(arguments={} of Symbol => String)
27 | valid_params = [
28 | :ignore_indices,
29 | :ignore_unavailable,
30 | :allow_no_indices,
31 | :expand_wildcards,
32 | :verbose
33 | ]
34 |
35 | method = "GET"
36 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_segments"
37 |
38 | params = Utils.__validate_and_extract_params arguments, valid_params
39 | body = nil
40 |
41 | perform_request(method, path, params, body).body
42 | end
43 | end
44 | end
45 | end
46 | end
47 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/shard_stores.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Provides low-level information about shards (allocated nodes, exceptions, ...)
7 | #
8 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
9 | # @option arguments [List] :status A comma-separated list of statuses used to filter on shards to get store information for (options: green, yellow, red, all)
10 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
11 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
12 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
13 | # @option arguments [String] :operation_threading
14 | #
15 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html
16 | #
17 | def shard_stores(arguments={} of Symbol => String)
18 | valid_params = [
19 | :status,
20 | :ignore_unavailable,
21 | :allow_no_indices,
22 | :expand_wildcards,
23 | :operation_threading ]
24 | method = "GET"
25 | path = Utils.__pathify Utils.__escape(arguments[:index].as(String)), "_shard_stores"
26 | params = Utils.__validate_and_extract_params arguments, valid_params
27 | body = nil
28 |
29 | perform_request(method, path, params, body).body
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/shrink.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Copy an existing index into a new index with a fewer number of primary shards
7 | #
8 | # @option arguments [String] :index The name of the source index to shrink (*Required*)
9 | # @option arguments [String] :target The name of the target index to shrink into (*Required*)
10 | # @option arguments [Hash] :body The configuration for the target index (`settings` and `aliases`)
11 | # @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active
12 | # @option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating
13 | # shards in the cluster
14 | # @option arguments [Time] :timeout Explicit operation timeout
15 | # @option arguments [Time] :master_timeout Specify timeout for connection to master
16 | #
17 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html
18 | #
19 | def shrink(arguments={} of Symbol => String)
20 | if !arguments.has_key?(:index) || !arguments.has_key?(:target)
21 | raise ArgumentError.new("Required argument 'index' or 'target' missing")
22 | end
23 |
24 | valid_params = [
25 | :wait_for_active_shards,
26 | :wait_for_no_relocating_shards,
27 | :timeout,
28 | :master_timeout
29 | ]
30 |
31 | source = arguments.delete(:index)
32 | target = arguments.delete(:target)
33 |
34 | if arguments.has_key? :body
35 | arg_body = arguments.delete(:body)
36 | else
37 | arg_body = nil
38 | end
39 |
40 | method = "PUT"
41 | path = Utils.__pathify(source.as(String), "_shrink", target.as(String))
42 | params = Utils.__validate_and_extract_params arguments, valid_params
43 | body = arg_body
44 |
45 | perform_request(method, path, params, body).body
46 | end
47 | end
48 | end
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/snapshot_index.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # When using the shared storage gateway, manually trigger the snapshot operation.
7 | #
8 | # @deprecated The shared gateway has been deprecated [https://github.com/elasticsearch/elasticsearch/issues/2458]
9 | #
10 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
11 | # to perform the operation on all indices
12 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
13 | # no concrete indices. (This includes `_all` string or when no
14 | # indices have been specified)
15 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
16 | # are open, closed or both. (options: open, closed)
17 | # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
18 | # `missing` ones (options: none, missing) @until 1.0
19 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
20 | # unavailable (missing, closed, etc)
21 | #
22 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/
23 | #
24 | def snapshot_index(arguments={} of Symbol => String)
25 | valid_params = [
26 | :ignore_indices,
27 | :ignore_unavailable,
28 | :allow_no_indices,
29 | :expand_wildcards
30 | ]
31 |
32 | method = "POST"
33 | path = Utils.__pathify Utils.__listify(arguments[:index].as(String)), "_gateway/snapshot"
34 |
35 | params = Utils.__validate_and_extract_params arguments, valid_params
36 | body = nil
37 |
38 | perform_request(method, path, params, body).body
39 | end
40 | end
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/update_aliases.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Perform multiple operation on index aliases in a single request.
7 | #
8 | # Pass the `actions` (add, remove) in the `body` argument.
9 | #
10 | # @example Add multiple indices to a single alias
11 | #
12 | # client.indices.update_aliases body: {
13 | # actions: [
14 | # { add: { index: 'logs-2013-06', alias: 'year-2013' } },
15 | # { add: { index: 'logs-2013-05', alias: 'year-2013' } }
16 | # ]
17 | # }
18 | #
19 | # @example Swap an alias (atomic operation)
20 | #
21 | # client.indices.update_aliases body: {
22 | # actions: [
23 | # { remove: { index: 'logs-2013-06', alias: 'current-month' } },
24 | # { add: { index: 'logs-2013-07', alias: 'current-month' } }
25 | # ]
26 | # }
27 | #
28 | # @option arguments [Hash] :body The operations definition and other configuration (*Required*)
29 | # @option arguments [Time] :timeout Explicit operation timeout
30 | #
31 | # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
32 | #
33 | def update_aliases(arguments={} of Symbol => String)
34 | if !arguments.has_key?(:body)
35 | raise ArgumentError.new("Required argument 'body' missing")
36 | end
37 | valid_params = [ :timeout ]
38 |
39 | method = "POST"
40 | path = "_aliases"
41 |
42 | params = Utils.__validate_and_extract_params arguments, valid_params
43 | body = arguments[:body]
44 |
45 | perform_request(method, path, params, body).body
46 | end
47 | end
48 | end
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/indices/upgrade.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions
5 |
6 | # Upgrade the index or indices to the latest Lucene format.
7 | #
8 | # @option arguments [List] :index A comma-separated list of index names;
9 | # use `_all` or empty string to perform the operation on all indices
10 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored
11 | # when unavailable (missing or closed)
12 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression
13 | # resolves into no concrete indices.
14 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
15 | # that are open, closed or both. (options: open, closed)
16 | # @option arguments [Boolean] :wait_for_completion Specify whether the request should block until the all
17 | # segments are upgraded (default: true)
18 | #
19 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-upgrade.html
20 | #
21 | def upgrade(arguments={} of Symbol => String)
22 | valid_params = [
23 | :ignore_unavailable,
24 | :allow_no_indices,
25 | :expand_wildcards,
26 | :wait_for_completion ]
27 |
28 | method = "POST"
29 | path = "_upgrade"
30 | params = Utils.__validate_and_extract_params arguments, valid_params
31 | body = nil
32 |
33 | perform_request(method, path, params, body).body
34 | end
35 | end
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/info.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Return simple information about the cluster (name, version).
6 | #
7 | # @see http://elasticsearch.org/guide/
8 | #
9 | def info(arguments={} of Symbol => String)
10 | method = "GET"
11 | path = ""
12 | params = {} of String => String
13 | body = nil
14 |
15 | perform_request(method, path, params, body).body
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/ingest/delete_pipeline.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Ingest
4 | module Actions
5 |
6 | # Delete a speficied pipeline
7 | #
8 | # @option arguments [String] :id Pipeline ID (*Required*)
9 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
10 | # @option arguments [Time] :timeout Explicit operation timeout
11 | #
12 | # @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
13 | #
14 | def delete_pipeline(arguments={} of Symbol => String)
15 | if !arguments.has_key?(:id)
16 | raise ArgumentError.new("Required argument 'id' missing")
17 | end
18 | valid_params = [
19 | :master_timeout,
20 | :timeout ]
21 | method = "DELETE"
22 | path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id].as(String))
23 | params = Utils.__validate_and_extract_params arguments, valid_params
24 | body = nil
25 |
26 | perform_request(method, path, params, body).body
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/ingest/get_pipeline.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Ingest
4 | module Actions
5 |
6 | # Return a specified pipeline
7 | #
8 | # @option arguments [String] :id Comma separated list of pipeline ids (wildcards supported).
9 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
10 | #
11 | # @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
12 | #
13 | def get_pipeline(arguments={} of Symbol => String)
14 | if !arguments.has_key?(:id)
15 | raise ArgumentError.new("Required argument 'id' missing")
16 | end
17 | valid_params = [
18 | :master_timeout ]
19 | method = "GET"
20 | path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id].as(String))
21 | params = Utils.__validate_and_extract_params arguments, valid_params
22 | body = nil
23 |
24 | perform_request(method, path, params, body).body
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/ingest/put_pipeline.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Ingest
4 | module Actions
5 |
6 | # Add or update a specified pipeline
7 | #
8 | # @option arguments [String] :id Pipeline ID (*Required*)
9 | # @option arguments [Hash] :body The ingest definition (*Required*)
10 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
11 | # @option arguments [Time] :timeout Explicit operation timeout
12 | #
13 | # @see https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
14 | #
15 | def put_pipeline(arguments={} of Symbol => String)
16 | if !arguments.has_key?(:id) || !arguments.has_key?(:body)
17 | raise ArgumentError.new("Required argument 'body' missing")
18 | end
19 | valid_params = [
20 | :master_timeout,
21 | :timeout ]
22 | method = "PUT"
23 | path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id].as(String))
24 |
25 | params = Utils.__validate_and_extract_params arguments, valid_params
26 | body = arguments[:body]
27 |
28 | perform_request(method, path, params, body).body
29 | end
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/ingest/simulate.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Ingest
4 | module Actions
5 |
6 | # Execute a specific pipeline against the set of documents provided in the body of the request
7 | #
8 | # @option arguments [String] :id Pipeline ID
9 | # @option arguments [Hash] :body The pipeline definition (*Required*)
10 | # @option arguments [Boolean] :verbose Verbose mode. Display data output for each processor
11 | # in executed pipeline
12 | #
13 | # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html
14 | #
15 | def simulate(arguments={} of Symbol => String)
16 | if !arguments.has_key?(:body)
17 | raise ArgumentError.new("Required argument 'body' missing")
18 | end
19 | valid_params = [
20 | :verbose ]
21 | method = "GET"
22 | path = Utils.__pathify "_ingest/pipeline", Utils.__escape(arguments[:id].as(String)), "_simulate"
23 | params = Utils.__validate_and_extract_params arguments, valid_params
24 | body = arguments[:body]
25 |
26 | perform_request(method, path, params, body).body
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/list_benchmarks.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Return a list of running benchmarks
6 | #
7 | # @example
8 | #
9 | # client.list_benchmarks
10 | #
11 | # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
12 | # to perform the operation on all indices
13 | # @option arguments [String] :type The name of the document type
14 | #
15 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html
16 | #
17 | def list_benchmarks(arguments={} of Symbol => String)
18 | method = "GET"
19 | path = "_bench"
20 | params = {} of String => String
21 | body = nil
22 |
23 | perform_request(method, path, params, body).body
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/nodes/hot_threads.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Nodes
4 | module Actions
5 |
6 | # Returns information about the hottest threads in the cluster or on a specific node as a String.
7 | #
8 | #
9 | # The information is returned as text, and allows you to understand what are currently
10 | # the most taxing operations happening in the cluster, for debugging or monitoring purposes.
11 | #
12 | # @example Return 10 hottest threads
13 | #
14 | # client.nodes.hot_threads threads: 10
15 | #
16 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information;
17 | # use `_local` to return information from the node you're connecting to,
18 | # leave empty to get information from all nodes
19 | # @option arguments [Time] :interval The interval for the second sampling of threads
20 | # @option arguments [Number] :snapshots Number of samples of thread stacktrace (default: 10)
21 | # @option arguments [Number] :threads Specify the number of threads to provide information for (default: 3)
22 | # @option arguments [String] :type The type to sample (default: cpu) (options: cpu, wait, block)
23 | # @option arguments [Time] :timeout Explicit operation timeout
24 | #
25 | # @return [String]
26 | #
27 | # @see http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/
28 | #
29 | def hot_threads(arguments={} of Symbol => String)
30 | valid_params = [
31 | :interval,
32 | :snapshots,
33 | :threads,
34 | :type,
35 | :timeout ]
36 |
37 | if arguments.has_key? :node_id
38 | node_id = arguments[:node_id]
39 | else
40 | node_id = ""
41 | end
42 |
43 | method = "GET"
44 | path = Utils.__pathify "_nodes", Utils.__listify(node_id), "hot_threads"
45 |
46 | params = Utils.__validate_and_extract_params arguments, valid_params
47 | body = nil
48 |
49 | perform_request(method, path, params, body).body
50 | end
51 | end
52 | end
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/nodes/shutdown.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Nodes
4 | module Actions
5 |
6 | # Shutdown one or all nodes
7 | #
8 | # @example Shut down node named _Bloke_
9 | #
10 | # client.nodes.shutdown node_id: 'Bloke'
11 | #
12 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to perform the operation on; use
13 | # `_local` to shutdown the node you're connected to, leave empty to
14 | # shutdown all nodes
15 | # @option arguments [Time] :delay Set the delay for the operation (default: 1s)
16 | # @option arguments [Boolean] :exit Exit the JVM as well (default: true)
17 | #
18 | # @see http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/
19 | #
20 | def shutdown(arguments={} of Symbol => String)
21 | valid_params = [
22 | :delay,
23 | :exit ]
24 |
25 | if arguments.has_key? :node_id
26 | node_id = arguments[:node_id]
27 | else
28 | node_id = ""
29 | end
30 |
31 | method = "POST"
32 | path = Utils.__pathify "_cluster/nodes", Utils.__listify(node_id), "_shutdown"
33 |
34 | params = Utils.__validate_and_extract_params arguments, valid_params
35 | body = nil
36 |
37 | perform_request(method, path, params, body).body
38 | end
39 | end
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/ping.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Returns true if the cluster returns a successful HTTP response, false otherwise.
6 | #
7 | # @example
8 | #
9 | # client.ping
10 | #
11 | # @see http://elasticsearch.org/guide/
12 | #
13 | def ping(arguments={} of Symbol => String)
14 | method = "HEAD"
15 | path = ""
16 | params = {} of String => String
17 | body = nil
18 |
19 | begin
20 | perform_request(method, path, params, body).status == 200 ? true : false
21 | rescue e : Exception
22 | if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not\s*Found|404|ConnectionFailed/i
23 | false
24 | else
25 | raise e
26 | end
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/search_shards.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Actions
4 |
5 | # Returns the names of indices and shards on which a search request would be executed
6 | #
7 | # @option arguments [String] :index The name of the index
8 | # @option arguments [String] :type The type of the document
9 | # @option arguments [String] :preference Specify the node or shard the operation should be performed on
10 | # (default: random)
11 | # @option arguments [String] :routing Specific routing value
12 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
13 | # (default: false)
14 | # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
15 | # unavailable (missing or closed)
16 | # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves
17 | # into no concrete indices.
18 | # (This includes `_all` or when no indices have been specified)
19 | # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
20 | # that are open, closed or both. (options: open, closed)
21 | #
22 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-shards.html
23 | #
24 | def search_shards(arguments={} of Symbol => String)
25 | valid_params = [
26 | :preference,
27 | :routing,
28 | :local,
29 | :ignore_unavailable,
30 | :allow_no_indices,
31 | :expand_wildcards ]
32 | method = "GET"
33 | path = Utils.__pathify( Utils.__listify(arguments[:index].as(String)), Utils.__listify(arguments[:type].as(String)), "_search_shards" )
34 | params = Utils.__validate_and_extract_params arguments, valid_params
35 | body = nil
36 |
37 | perform_request(method, path, params, body).body
38 | end
39 | end
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/create_repository.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Create a repository for storing snapshots
7 | #
8 | # @example Create a repository at `/tmp/backup`
9 | #
10 | # client.snapshot.create_repository repository: 'my-backups',
11 | # body: {
12 | # type: 'fs',
13 | # settings: { location: '/tmp/backup', compress: true }
14 | # }
15 | #
16 | # @option arguments [String] :repository A repository name (*Required*)
17 | # @option arguments [Hash] :body The repository definition (*Required*)
18 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
19 | # @option arguments [Time] :timeout Explicit operation timeout
20 | #
21 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_repositories
22 | #
23 | def create_repository(arguments={} of Symbol => String)
24 | if !arguments.has_key?(:repository) || !arguments.has_key?(:body)
25 | raise ArgumentError.new("Required argument 'body' or 'repository' missing")
26 | end
27 | valid_params = [
28 | :repository,
29 | :master_timeout,
30 | :timeout ]
31 |
32 | repository = arguments.delete(:repository) || ""
33 |
34 | method = "PUT"
35 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository) )
36 |
37 | params = Utils.__validate_and_extract_params arguments, valid_params
38 | body = arguments[:body]
39 |
40 | perform_request(method, path, params, body).body
41 | end
42 | end
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/delete.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Delete a snapshot from the repository
7 | #
8 | # @note Will also abort a currently running snapshot.
9 | #
10 | # @example Delete the `snapshot-1` snapshot
11 | #
12 | # client.snapshot.delete repository: 'my-backups', snapshot: 'snapshot-1'
13 | #
14 | # @option arguments [String] :repository A repository name (*Required*)
15 | # @option arguments [String] :snapshot A snapshot name (*Required*)
16 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
17 | # @option arguments [Number,List] :ignore The list of HTTP errors to ignore
18 | #
19 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
20 | #
21 | def delete(arguments={} of Symbol => String)
22 | if !arguments.has_key?(:repository) || !arguments.has_key?(:snapshot)
23 | raise ArgumentError.new("Required argument 'snapshot' or 'repository' missing")
24 | end
25 | valid_params = [
26 | :master_timeout ]
27 |
28 | repository = arguments.delete(:repository)
29 | snapshot = arguments.delete(:snapshot)
30 | ignore = arguments.delete(:ignore) || ""
31 |
32 | method = "DELETE"
33 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository.as(String)), Utils.__listify(snapshot.as(String)) )
34 |
35 | params = Utils.__validate_and_extract_params arguments, valid_params
36 | body = nil
37 |
38 | perform_request(method, path, params, body).body
39 |
40 | end
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/delete_repository.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Delete a specific repository or repositories
7 | #
8 | # @example Delete the `my-backups` repository
9 | #
10 | # client.snapshot.delete_repository repository: 'my-backups'
11 | #
12 | # @option arguments [List] :repository A comma-separated list of repository names (*Required*)
13 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
14 | # @option arguments [Time] :timeout Explicit operation timeout
15 | # @option arguments [Number,List] :ignore The list of HTTP errors to ignore
16 | #
17 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
18 | #
19 | def delete_repository(arguments={} of Symbol => String)
20 | if !arguments.has_key?(:repository)
21 | raise ArgumentError.new("Required argument 'repository' missing")
22 | end
23 |
24 | valid_params = [
25 | :master_timeout,
26 | :timeout ]
27 |
28 | repository = arguments.delete(:repository) || ""
29 | ignore = arguments.delete(:ignore) || ""
30 |
31 | method = "DELETE"
32 | path = Utils.__pathify( "_snapshot", Utils.__listify(repository.as(String)) )
33 |
34 | params = Utils.__validate_and_extract_params arguments, valid_params
35 | body = nil
36 |
37 | if ignore.includes?("404")
38 | Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
39 | else
40 | perform_request(method, path, params, body).body
41 | end
42 | end
43 | end
44 | end
45 | end
46 | end
47 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/get.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Return information about specific (or all) snapshots
7 | #
8 | # @example Return information about the `snapshot-2` snapshot
9 | #
10 | # client.snapshot.get repository: 'my-backup', snapshot: 'snapshot-2'
11 | #
12 | # @example Return information about multiple snapshots
13 | #
14 | # client.snapshot.get repository: 'my-backup', snapshot: ['snapshot-2', 'snapshot-3']
15 | #
16 | # @example Return information about all snapshots in the repository
17 | #
18 | # client.snapshot.get repository: 'my-backup', snapshot: '_all'
19 | #
20 | # @option arguments [String] :repository A repository name (*Required*)
21 | # @option arguments [List] :snapshot A comma-separated list of snapshot names (*Required*)
22 | # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
23 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
24 | # @option arguments [Number,List] :ignore The list of HTTP errors to ignore
25 | #
26 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
27 | #
28 | def get(arguments={} of Symbol => String)
29 | if !arguments.has_key?(:repository) || !arguments.has_key?(:snapshot)
30 | raise ArgumentError.new("Required argument 'snapshot' or 'repository' missing")
31 | end
32 |
33 | valid_params = [
34 | :ignore_unavailable,
35 | :master_timeout ]
36 |
37 | repository = arguments.delete(:repository)
38 | snapshot = arguments.delete(:snapshot)
39 |
40 | method = "GET"
41 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository.as(String)), Utils.__listify(snapshot.as(String)) )
42 | arguments = Utils.__sort_booleans(arguments)
43 | params = Utils.__validate_and_extract_params arguments, valid_params
44 | body = nil
45 |
46 | perform_request(method, path, params, body).body
47 | end
48 | end
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/get_repository.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Get information about snapshot repositories or a specific repository
7 | #
8 | # @example Get all repositories
9 | #
10 | # client.snapshot.get_repository
11 | #
12 | # @example Get a specific repository
13 | #
14 | # client.snapshot.get_repository repository: 'my-backups'
15 | #
16 | # @option arguments [List] :repository A comma-separated list of repository names. Leave blank or use `_all`
17 | # to get a list of repositories
18 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
19 | # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
20 | # (default: false)
21 | # @option arguments [Number,List] :ignore The list of HTTP errors to ignore
22 | #
23 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
24 | #
25 | def get_repository(arguments={} of Symbol => String)
26 | valid_params = [
27 | :master_timeout,
28 | :local ]
29 |
30 | repository = arguments.delete(:repository) || ""
31 | ignore = arguments.delete(:ignore) || ""
32 |
33 | method = "GET"
34 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository.as(String)) )
35 |
36 | params = Utils.__validate_and_extract_params arguments, valid_params
37 | body = nil
38 |
39 | perform_request(method, path, params, body).body
40 | end
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/status.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Return information about a running snapshot
7 | #
8 | # @example Return information about all currently running snapshots
9 | #
10 | # client.snapshot.status repository: 'my-backups', human: true
11 | #
12 | # @example Return information about a specific snapshot
13 | #
14 | # client.snapshot.status repository: 'my-backups', human: true
15 | #
16 | # @option arguments [String] :repository A repository name
17 | # @option arguments [List] :snapshot A comma-separated list of snapshot names
18 | # @option arguments [Boolean] :ignore_unavailable Whether to ignore unavailable snapshots, defaults to # false which means a SnapshotMissingException is thrown
19 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
20 | # @option arguments [Number,List] :ignore The list of HTTP errors to ignore
21 | #
22 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html#_snapshot_status
23 | #
24 | def status(arguments={} of Symbol => String)
25 | valid_params = [
26 | :ignore_unavailable,
27 | :master_timeout ]
28 |
29 | repository = arguments.delete(:repository)
30 | snapshot = arguments.delete(:snapshot)
31 | ignore = arguments.delete(:ignore) || ""
32 |
33 | method = "GET"
34 |
35 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository.as(String)), Utils.__escape(snapshot.as(String)), "_status")
36 | arguments = Utils.__sort_booleans(arguments)
37 | params = Utils.__validate_and_extract_params arguments, valid_params
38 | body = nil
39 |
40 | perform_request(method, path, params, body).body
41 | end
42 | end
43 | end
44 | end
45 | end
46 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/snapshot/verify_repository.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions
5 |
6 | # Explicitly perform the verification of a repository
7 | #
8 | # @option arguments [String] :repository A repository name (*Required*)
9 | # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
10 | # @option arguments [Time] :timeout Explicit operation timeout
11 | #
12 | # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
13 | #
14 | def verify_repository(arguments={} of Symbol => String)
15 | if !arguments.has_key?(:repository)
16 | raise ArgumentError.new("Required argument 'repository' missing")
17 | end
18 | valid_params = [
19 | :repository,
20 | :master_timeout,
21 | :timeout ]
22 |
23 | repository = arguments.delete(:repository)
24 | method = "POST"
25 | path = Utils.__pathify( "_snapshot", Utils.__escape(repository.as(String)), "_verify" )
26 | params = Utils.__validate_and_extract_params arguments, valid_params
27 | body = nil
28 |
29 | perform_request(method, path, params, body).body
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/tasks/cancel.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Tasks
4 | module Actions
5 |
6 | # Cancel a specific task
7 | #
8 | # @option arguments [Number] :task_id Cancel the task with specified id
9 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned
10 | # information; use `_local` to return information from the node
11 | # you're connecting to, leave empty to get information from all nodes
12 | # @option arguments [List] :actions A comma-separated list of actions that should be returned.
13 | # Leave empty to return all.
14 | # @option arguments [String] :parent_node Cancel tasks with specified parent node.
15 | # @option arguments [Number] :parent_task Cancel tasks with specified parent task id.
16 | # Set to -1 to cancel all.
17 | #
18 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks-cancel.html
19 | #
20 | def cancel(arguments={} of Symbol => String)
21 | valid_params = [
22 | :node_id,
23 | :actions,
24 | :parent_node,
25 | :parent_task ]
26 |
27 | arguments = arguments.clone
28 |
29 | task_id = arguments.delete(:task_id) || ""
30 |
31 | method = "POST"
32 | path = Utils.__pathify( "_tasks", Utils.__escape(task_id.as(String)), "_cancel" )
33 | params = Utils.__validate_and_extract_params arguments, valid_params
34 | body = nil
35 |
36 | perform_request(method, path, params, body).body
37 | end
38 | end
39 | end
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/tasks/get.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Tasks
4 | module Actions
5 |
6 | # Return information about a specific task
7 | #
8 | # @option arguments [String] :task_id Return the task with specified id (node_id:task_number)
9 | # @option arguments [Boolean] :wait_for_completion Wait for the matching tasks to complete (default: false)
10 | #
11 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html
12 | #
13 | def get(arguments={} of Symbol => String)
14 | valid_params = [ :wait_for_completion ]
15 |
16 | arguments = arguments.clone
17 |
18 | task_id = arguments.delete(:task_id) || ""
19 |
20 | method = "GET"
21 | path = Utils.__pathify "_tasks", Utils.__escape(task_id.as(String))
22 | params = Utils.__validate_and_extract_params arguments, valid_params
23 | body = nil
24 |
25 | perform_request(method, path, params, body).body
26 | end
27 | end
28 | end
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/actions/tasks/list.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Tasks
4 | module Actions
5 |
6 | # Return the list of tasks
7 | #
8 | # @option arguments [Number] :task_id Return the task with specified id
9 | # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned
10 | # information; use `_local` to return information from the node
11 | # you're connecting to, leave empty to get information from all nodes
12 | # @option arguments [List] :actions A comma-separated list of actions that should be returned.
13 | # Leave empty to return all.
14 | # @option arguments [Boolean] :detailed Return detailed task information (default: false)
15 | # @option arguments [String] :parent_node Return tasks with specified parent node.
16 | # @option arguments [Number] :parent_task Return tasks with specified parent task id.
17 | # Set to -1 to return all.
18 | # @option arguments [String] :group_by Group tasks by nodes or parent/child relationships
19 | # Options: nodes, parents
20 | # @option arguments [Boolean] :wait_for_completion Wait for the matching tasks to complete (default: false)
21 | #
22 | # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks-list.html
23 | #
24 | def list(arguments={} of Symbol => String)
25 | valid_params = [
26 | :node_id,
27 | :actions,
28 | :detailed,
29 | :parent_node,
30 | :parent_task,
31 | :group_by,
32 | :wait_for_completion ]
33 |
34 | arguments = arguments.clone
35 |
36 | task_id = arguments.delete(:task_id) || ""
37 |
38 | method = "GET"
39 | path = Utils.__pathify( "_tasks", Utils.__escape(task_id.as(String)) )
40 | params = Utils.__validate_and_extract_params arguments, valid_params
41 | body = nil
42 |
43 | perform_request(method, path, params, body).body
44 | end
45 | end
46 | end
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/cat.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cat
4 | module Actions; end
5 |
6 | # Client for the "cat" namespace (includes the {Cat::Actions} methods)
7 | #
8 | class CatClient < Common::Client
9 | include Cat::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/cluster.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Cluster
4 | module Actions; end
5 |
6 | # Client for the "cluster" namespace (includes the {Cluster::Actions} methods)
7 | #
8 | class ClusterClient < Common::Client
9 | include Cluster::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/indices.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Indices
4 | module Actions; end
5 |
6 | # Client for the "indices" namespace (includes the {Indices::Actions} methods)
7 | #
8 | class IndicesClient < Common::Client
9 | include Indices::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/ingest.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Ingest
4 | module Actions; end
5 |
6 | # Client for the "ingest" namespace (includes the {Ingest::Actions} methods)
7 | #
8 | class IngestClient < Common::Client
9 | include Ingest::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/nodes.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Nodes
4 | module Actions; end
5 |
6 | # Client for the "nodes" namespace (includes the {Nodes::Actions} methods)
7 | #
8 | class NodesClient < Common::Client
9 | include Nodes::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/snapshot.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Snapshot
4 | module Actions; end
5 |
6 | # Client for the "snapshot" namespace (includes the {Snapshot::Actions} methods)
7 | #
8 | class SnapshotClient < Common::Client
9 | include Snapshot::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/namespace/tasks.cr:
--------------------------------------------------------------------------------
1 | module Elasticsearch
2 | module API
3 | module Tasks
4 | module Actions; end
5 |
6 | # Client for the "tasks" namespace (includes the {Tasks::Actions} methods)
7 | #
8 | class TasksClient < Common::Client
9 | include Tasks::Actions
10 | end
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/elasticsearch/api/version.cr:
--------------------------------------------------------------------------------
1 | VERSION = "0.11"
2 |
--------------------------------------------------------------------------------
/src/version.cr:
--------------------------------------------------------------------------------
1 | VERSION = "0.11"
2 |
--------------------------------------------------------------------------------
/test/integration/actions/abort_benchmark_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsAbortBenchmarkTest
6 | include Spec
7 |
8 | context "Actions: Abort Benchmark: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Abort benchmark on query" do
12 | subject.abort_benchmark({:name => "test_benchmark"})
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/benchmark_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsBenchmarkTest
6 | include Spec
7 |
8 | context "Actions: Benchmark: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get benchmark on query" do
12 | subject.benchmark({:body => {"name" => "test_benchmark",
13 | "competitors" => [
14 | {"name" => "query_1",
15 | "requests" => [
16 | {"query" => {"match" => {"_all" => "a*"}}}
17 | ]}]
18 | }
19 | })
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/actions/bulk_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsBulkTest
6 | include Spec
7 |
8 | context "Actions: Bulk: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Bulk" do
12 | subject.indices.create({:index => "test"})
13 | subject.bulk({:body => [
14 | { "index" => { "_index" => "test", "_type" => "mytype", "_id" => "1"}},
15 | { "title" => "foo" },
16 | { "delete" => { "_index" => "test", "_type" => "mytype", "_id" => "2"}},
17 | ]}
18 | )
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/actions/clear_scroll_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsClearScrollTest
6 | include Spec
7 |
8 | context "Actions: Clear Scroll: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Clear a scroll" do
12 | subject.clear_scroll({:body => {} of Symbol => String, :scroll_id => "_all"})
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/count_percolate_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionCountPercolateTest
6 | include Spec
7 |
8 | context "Action: Count Percolate: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "Count Percolate" do
16 | subject.indices.create({:index => "test"})
17 | subject.count_percolate({:index => "test", :type => "my-type", :id => "123"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/actions/count_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsCountTest
6 | include Spec
7 |
8 | context "Actions: Count: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Count all documents" do
12 | subject.count
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/create_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionCreateDocumentTest
6 | include Spec
7 |
8 | context "Action: Create Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should create a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | end
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/test/integration/actions/delete_by_query_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionDeleteByQueryTest
6 | include Spec
7 |
8 | context "Action: Delete Document by Query: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should delete a document by query" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.delete_by_query({:index => "test_index", :q => "title: Test 1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/delete_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionDeleteDocumentTest
6 | include Spec
7 |
8 | context "Action: Delete Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should delete a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.delete({:index => "test_index", :type => "type_1", :id => "1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/exists_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionExistDocumentTest
6 | include Spec
7 |
8 | context "Action: Exists Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "check if a document exists" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.exists({:index => "test_index", :type => "type_1", :id => "1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/explain_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionExplainDocumentTest
6 | include Spec
7 |
8 | context "Action: Explain Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "explain a Document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.explain({:index => "test_index", :type => "type_1", :id => "1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/get_source_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionGetSourceDocumentTest
6 | include Spec
7 |
8 | context "Action: Get Source Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get a source document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.get_source({:index => "test_index", :type => "type_1", :id => "1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/get_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionGetDocumentTest
6 | include Spec
7 |
8 | context "Action: Get Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.get({:index => "test_index", :type => "type_1", :id => "1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/index_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionIndexTest
6 | include Spec
7 |
8 | context "Action: Index: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should create an index document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.index({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | end
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/test/integration/actions/info_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsInfoTest
6 | include Spec
7 |
8 | context "Actions: Info: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Show cluster info" do
12 | subject.info
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/list_benchmarks_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsListBenchmarksTest
6 | include Spec
7 |
8 | context "Actions: List Benchmarks: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "List Benchmarks" do
12 | subject.list_benchmarks
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/mget_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionMultipleGetDocumentTest
6 | include Spec
7 |
8 | context "Action: Multiple Get Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.mget({:index => "test_index", :type => "type_id", :body => { "ids" => ["1", "2", "3"] }})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/mtermvectors_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionMultipleTermVectorsTest
6 | include Spec
7 |
8 | context "Action: Multiple Term Vectors: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get multiple term vectors" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.mtermvectors({:index => "test_index", :type => "type_id", :body => { "ids" => ["1", "2", "3"] }})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/ping_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionsPingTest
6 | include Spec
7 |
8 | context "Actions: Ping: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Ping test" do
12 | subject.ping
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/actions/search_shards_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionSearchShardsTest
6 | include Spec
7 |
8 | context "Action: Search Shards: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get the shards where search query runs" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.search_shards({:index => "test_index", :type => "type_id"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/search_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionSearchDocumentTest
6 | include Spec
7 |
8 | context "Action: Search Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should search a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.search({:index => "test_index", :q => "title:Test 1"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/termvectors_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionTermVectorsTest
6 | include Spec
7 |
8 | context "Action: Term Vectors: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get term vectors" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.termvectors({:index => "test_index", :type => "type_id", :id => "1" })
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/update_by_query_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionUpdateByQueryDocumentTest
6 | include Spec
7 |
8 | context "Action: Update Document By Query: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should update a document by query" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.update_by_query({:index => "test_index"})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/actions/update_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ActionUpdateDocumentTest
6 | include Spec
7 |
8 | context "Action: Update Document: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should update a document" do
16 | subject.indices.create({:index => "test_index", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.create({:index => "test_index",
18 | :type => "type_1",
19 | :id => "1",
20 | :body => {
21 | "title" => "Test 1",
22 | "tags" => ["y", "z"]
23 | }})
24 | subject.update({:index => "test_index", :type => "type_1", :id => "1", :body => {"doc" => {"title" => "Updated" }}})
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/cat/allocation_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatAllocationTest
6 | include Spec
7 |
8 | context "Cat: Allocation" do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "help" do
16 | subject.cat.allocation({:help => true}).should match /^shards/
17 | end
18 |
19 | it "one index" do
20 | subject.indices.create({:index => "test"})
21 | subject.cat.allocation.as(String).should match /UNASSIGNED/
22 | end
23 |
24 | it "node id" do
25 | subject.indices.create({:index => "test"})
26 | subject.cat.allocation({:node_id => "_master"}).should match /UNASSIGNED/
27 | end
28 |
29 | it "all nodes" do
30 | subject.indices.create({:index => "test"})
31 | subject.cat.allocation({:node_id => "*"}).should match /UNASSIGNED/
32 | end
33 |
34 | it "column headers" do
35 | subject.cat.allocation({:v => true}).should match /^shards/
36 | end
37 |
38 | it "select columns" do
39 | subject.cat.allocation({:h => "disk.percent,node", :v => true}).should match /^disk\.percent/
40 | end
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/test/integration/cat/count_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatCountTest
6 | include Spec
7 |
8 | context "Cat: Count: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "index1"})
13 | #subject.indices.delete({:index => "index2"})
14 | end
15 |
16 | it "help" do
17 | subject.cat.count({:help => true}).should match /^epoch/
18 | end
19 |
20 | it "test count" do
21 | subject.cat.count.should match /.*0/
22 | #subject.index({:index => "index1", :type => "type1", :id => "1", :body => {"foo" => "bar"}, :refresh => true})
23 | #subject.cat.count.should match /.*1/
24 | #subject.index({:index => "index2", :type => "type2", :id => "1", :body => {"foo" => "bar"}, :refresh => true})
25 | #subject.cat.count.should match /.*2/
26 | # shard allocation exception I need to dig into this
27 | subject.cat.count({:h => "count", :v => true}).should match /^count/
28 | #subject.cat.count({:index => "index1"}).should match /.*1/
29 | #subject.cat.count({:index => "index2"}).should match /(?=.*2)(?=.*epoch)/
30 | end
31 | end
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/test/integration/cat/fielddata_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatFieldDataTest
6 | include Spec
7 |
8 | context "Cat: FieldData: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "index"})
13 | end
14 |
15 | it "help" do
16 | subject.cat.fielddata({:help => true}).should match /field/
17 | end
18 |
19 | it "test field data output" do
20 | (subject.cat.fielddata.as(String).empty?).should be_true
21 | subject.indices.create({:index => "index", :body => {"mappings" => {
22 | "type" => {
23 | "properties" => {
24 | "foo" => {
25 | "type" => "text",
26 | "fielddata" => true
27 | }
28 | }
29 | }
30 | },
31 | "settings" => {
32 | "number_of_shards" => "1"
33 | }
34 | }})
35 | #subject.index({:index => "index", :type => "type", :body => {"foo" => "bar"}, :refresh => true})
36 | #subject.search({:index => "index", :body => {"query" => {"match_all" => {} of String => String}, "sort" => "foo"} })
37 | subject.cat.fielddata({:h => "field, size", :v => true}).should match /^field/
38 | subject.cat.fielddata({:h => "field, size", :fields => "notfoo,foo", :v => true}).should match /^field/
39 | subject.cat.fielddata({:h => "field, size", :fields => "notfoo", :v => true}).should match /^field/
40 | end
41 | end
42 | end
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/test/integration/cat/health_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatHealthTest
6 | include Spec
7 |
8 | context "Cat: Health: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.health({:help => true}).should match /status/
13 | end
14 |
15 | it "test field data output" do
16 | subject.cat.health.should match /(green|yellow)/
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cat/help_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatHelpTest
6 | include Spec
7 |
8 | context "Cat: Help: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | (subject.cat.help.as(String).empty?).should be_false
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/cat/indices_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatIndicesTest
6 | include Spec
7 |
8 | context "Cat: Indices: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "index1"})
13 | end
14 |
15 | it "help" do
16 | (subject.cat.indices.as(String).empty?).should be_true
17 | end
18 |
19 | it "test indices output" do
20 | (subject.cat.indices.as(String).empty?).should be_true
21 | subject.indices.create({:index => "index1", :body => {"settings" => {"number_of_shards" => "1",
22 | "number_of_replicas" => "0"}}})
23 | subject.cat.indices.should match /index1/
24 | end
25 |
26 | it "test indices output with wildcards" do
27 | subject.indices.create({:index => "index1"})
28 | subject.cat.indices({:index => "in*"}).should match /index1/
29 | end
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/test/integration/cat/master_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatMasterTest
6 | include Spec
7 |
8 | context "Cat: Master: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "master" do
12 | (subject.cat.master.as(String).empty?).should be_false
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/cat/nodeattrs_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatNodeAttrsTest
6 | include Spec
7 |
8 | context "Cat: NodeAttrs: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.nodeattrs({:help => true}).as(String).should match /node/
13 | end
14 |
15 | it "check attrs are not empty with columns" do
16 | subject.cat.nodeattrs({:v => true}).as(String).should match /^node/
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cat/nodes_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatNodesTest
6 | include Spec
7 |
8 | context "Cat: Nodes: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.nodes({:help => true}).as(String).should match /heap\.percent/
13 | end
14 |
15 | it "check nodes are not empty" do
16 | (subject.cat.nodes.as(String).empty?).should be_false
17 | end
18 |
19 | it "check nodes are not empty with columns" do
20 | subject.cat.nodes({:v => true}).as(String).should match /^ip/
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/integration/cat/pending_tasks_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatPendingTasksTest
6 | include Spec
7 |
8 | context "Cat: PendingTasks: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.pending_tasks({:help => true}).as(String).should match /insertOrder/
13 | end
14 |
15 | it "should be not empty tasks" do
16 | (subject.cat.pending_tasks.as(String).empty?).should be_true
17 | end
18 |
19 | it "check pending_tasks are not empty with columns" do
20 | subject.cat.pending_tasks({:v => true}).as(String).should match /^insertOrder/
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/integration/cat/plugins_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatPluginsTest
6 | include Spec
7 |
8 | context "Cat: Plugins: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.plugins({:help => true}).as(String).should match /^id/
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/cat/recovery_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatRecoveryTest
6 | include Spec
7 |
8 | context "Cat: Recovery: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.recovery({:help => true}).as(String).should match /index/
13 | end
14 |
15 | it "check recovery are not empty with columns" do
16 | subject.cat.nodes({:v => true}).as(String).should match /cpu/
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cat/repositories_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatRepositoriesTest
6 | include Spec
7 |
8 | context "Cat: Repositories: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | subject.snapshot.delete_repository({:repository => "test_cat_repo_2"})
14 | end
15 |
16 | it "help" do
17 | subject.cat.repositories({:help => true}).as(String).should match /^id/
18 | end
19 |
20 | it "should return repositories when created" do
21 | (subject.cat.repositories.as(String).empty?).should be_true
22 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
23 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
24 | subject.snapshot.create_repository({:repository => "test_cat_repo_2", :body => {"type" => "fs",
25 | "settings" => {"location" => "test_cat_repo_2_loc"}}})
26 | #subject.cat.repositories.should match /test_cat_repo_1/
27 | #subject.cat.repositories.should match /test_cat_repo_2/
28 | end
29 | end
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/test/integration/cat/segments_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatSegmentsTest
6 | include Spec
7 |
8 | context "Cat: Segments: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.segments({:help => true}).as(String).should match /segment/
13 | end
14 |
15 | it "check segments are not empty with columns" do
16 | subject.cat.segments({:v => true}).as(String).should match /segment/
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cat/shards_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatShardsTest
6 | include Spec
7 |
8 | context "Cat: Shards: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "index1"})
13 | end
14 |
15 | it "help" do
16 | (subject.cat.shards({:help => true}).as(String).empty?).should be_false
17 | end
18 |
19 | it "test shards output" do
20 | (subject.cat.shards.as(String).empty?).should be_true
21 | subject.indices.create({:index => "index1"})
22 | subject.cat.shards.should match /index1/
23 | end
24 |
25 | it "check shards are not empty with columns" do
26 | subject.cat.shards({:v => true}).as(String).should match /^index/
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/test/integration/cat/snapshots_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatSnapshotsTest
6 | include Spec
7 |
8 | context "Cat: Snapshots: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "index1"})
13 | subject.indices.delete({:index => "index2"})
14 | subject.snapshot.delete({:repository => "test_cat_repo_1", :snapshot => "snap1"})
15 | #subject.snapshot.delete({:repository => "test_cat_repo_1", :snapshot => "snap2"})
16 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
17 | end
18 |
19 | it "help" do
20 | subject.cat.repositories({:help => true}).as(String).should match /^id/
21 | end
22 |
23 | it "should return repositories when created" do
24 | (subject.cat.repositories.as(String).empty?).should be_true
25 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
26 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
27 | subject.cat.snapshots({:repository => "test_cat_repo_1"})
28 | subject.indices.create({:index => "index1", :body => {"settings" => {"number_of_shards" => "1",
29 | "number_of_replicas" => "0"}}})
30 | subject.indices.create({:index => "index2", :body => {"settings" => {"number_of_shards" => "1",
31 | "number_of_replicas" => "0"}}})
32 | subject.cluster.health({:wait_for_status => "green"})
33 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
34 | #subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap2", :wait_for_completion => true})
35 | subject.cat.snapshots({:repository => "test_cat_repo_1"}).as(JSON::Any)
36 | #subject.cat.snapshots({:repository => "test_cat_repo_1"}).as(String).should match /snap2/
37 | end
38 | end
39 | end
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/test/integration/cat/tasks_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatTasksTest
6 | include Spec
7 |
8 | context "Cat: Tasks: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.tasks({:help => true}).as(String).should match /transport/
13 | end
14 |
15 | it "check tasks are not empty with columns" do
16 | subject.cat.tasks({:v => true}).as(String).should match /^action/
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cat/thread_pool_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class CatThreadPoolTest
6 | include Spec
7 |
8 | context "Cat: Thread Pool: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "help" do
12 | subject.cat.thread_pool({:help => true}).as(String).should match /thread/
13 | end
14 |
15 | it "should return thread pools" do
16 | subject.cat.thread_pool.as(String).should match /bulk/
17 | end
18 |
19 | it "check thread pool are not empty with columns" do
20 | subject.cat.thread_pool({:v => true}).as(String).should match /^node/
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/integration/cluster/allocation_explain_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterAllocationExplainTest
6 | include Spec
7 |
8 | context "Cluster: Allocation Explain: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "Explain index allocation" do
16 | subject.indices.create({:index => "test"})
17 | subject.cluster.allocation_explain({:body => {"index" => "test", "shard" => "0", "primary" => "true"}})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/cluster/get_settings_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterGetSettingsTest
6 | include Spec
7 |
8 | context "Cluster: GetSettings: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get cluster settings" do
12 | subject.cluster.get_settings
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/cluster/health_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterHealthTest
6 | include Spec
7 |
8 | context "Cluster: Health: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "Get cluster health" do
16 | subject.indices.create({:index => "test"})
17 | subject.cluster.health({:wait_for_status => "green"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/cluster/put_settings_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterPutSettingsTest
6 | include Spec
7 |
8 | context "Cluster: Put Settings: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.cluster.put_settings({:body => {"transient" => {"cluster.routing.allocation.disable_allocation" => "false"}}})
13 | end
14 |
15 | it "Put settings" do
16 | subject.cluster.put_settings({:body => {"transient" => {"cluster.routing.allocation.disable_allocation" => "true"}}})
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/test/integration/cluster/reroute_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterRerouteTest
6 | include Spec
7 |
8 | context "Cluster: Reroute: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "Reroute" do
16 | subject.indices.create({:index => "test"})
17 | # skipping this for now as tests only have 1 node but theorically this should work just fine
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/cluster/state_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterStateTest
6 | include Spec
7 |
8 | context "Cluster: State: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get cluster state" do
12 | subject.cluster.state
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/cluster/stats_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class ClusterStatsTest
6 | include Spec
7 |
8 | context "Cluster: Stats: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get cluster stats" do
12 | subject.cluster.stats
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/indices/analyze_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesAnalyzeTest
6 | include Spec
7 |
8 | context "Indices: Analyze: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | #subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "basic test" do
16 | result = subject.indices.analyze({:body => {"text" => "Foo Bar", "analyzer" => "standard"}})
17 | result.as(JSON::Any).as_h.has_key?("tokens").should be_true
18 | end
19 |
20 | it "index and field" do
21 | # I seem to be a getting a 503 and no shard available exception
22 | #subject.indices.create({:index => "test", :body => {"mappings" => {
23 | # "test" => {
24 | # "properties" => {
25 | # "text" => {
26 | # "type" => "text",
27 | # "analyzer" => "standard"
28 | # }
29 | # }
30 | # }
31 | # }}})
32 | #result = subject.indices.analyze({:index => "test", :body => {"field" => "text", "text" => "Foo Bar!"}})
33 | #result.should match /foo/
34 | #result.as(JSON::Any).as_h.has_key?("tokens").should be_true
35 | end
36 | end
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/test/integration/indices/clear_cache_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesClearCacheTest
6 | include Spec
7 |
8 | context "Indices: Clear Cache: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "clear all caches" do
16 | subject.indices.clear_cache
17 | end
18 |
19 | it "clean fields for an index" do
20 | subject.indices.create({:index => "test"})
21 | subject.indices.clear_cache({:index => "test", :fields => true})
22 | end
23 | end
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/test/integration/indices/close_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesCloseTest
6 | include Spec
7 |
8 | context "Indices: Close: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "close an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.close({:index => "test"})
18 | subject.cat.indices.as(String).should match /close/
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/delete_alias_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesDeleteAliasTest
6 | include Spec
7 |
8 | context "Indices: Delete Alias: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "testind"})
13 | end
14 |
15 | it "delete an alias" do
16 | subject.indices.create({:index => "testind"})
17 | subject.indices.put_alias({:index => "testind", :name => "testali"})
18 | subject.cat.aliases.as(String).should match /testali/
19 | subject.indices.delete_alias({:index => "testind", :name => "testali"})
20 | (subject.cat.aliases.as(String).empty?).should be_true
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/integration/indices/delete_mapping_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesDeleteMappingTest
6 | include Spec
7 |
8 | context "Indices: Delete Mapping: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "delete a mapping" do
16 | subject.indices.create({:index => "test", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.indices.delete_mapping({:index => "test", :type => "type_1"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/delete_template_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesDeleteTemplateTest
6 | include Spec
7 |
8 | context "Indices: Delete Template: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "delete a template" do
12 | subject.indices.put_template({:name => "test", :body => {"order" => 0,
13 | "version" => 1,
14 | "template" => "test",
15 | "index_patterns" => "test-*",
16 | "settings" => {"number_of_shards" => "1",
17 | "number_of_replicas" => "0"}}})
18 | subject.indices.delete_template({:name => "test"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/delete_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesDeleteIndexTest
6 | include Spec
7 |
8 | context "Indices: Delete Index: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "delete an index" do
12 | subject.indices.create({:index => "test"})
13 | subject.indices.delete({:index => "test"})
14 | (subject.cat.indices.as(String).empty?).should be_true
15 | end
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/test/integration/indices/delete_warmer_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesDeleteWarmerTest
6 | include Spec
7 |
8 | context "Indices: Delete Warmer: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "delete a warmer" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.put_warmer({:index => "test", :name => "main", :body => { "query" => {
18 | "filtered" => {
19 | "filter" => {
20 | "term" => { "published" => true }
21 | }
22 | }
23 | },
24 | "sort" => [ "created_at" ]
25 | }})
26 | subject.indices.delete_warmer({:index => "test", :name => "main"})
27 | # This call causes an error and takes ages, investigate
28 | #(subject.indices.get_warmer({:index => "test", :name => "main"}).as_hash.empty?).should be_true
29 | end
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/test/integration/indices/exists_alias_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesExistsAliasTest
6 | include Spec
7 |
8 | context "Indices: Exists Alias: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it " check if alias exists" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.put_alias({:index => "test", :name => "testali"})
18 | subject.indices.exists_alias({:index => "test", :name => "testali"}).should be_true
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/exists_template_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesExistsTemplateTest
6 | include Spec
7 |
8 | context "Indices: Exists Template: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "template exists" do
12 | subject.indices.put_template({:name => "test", :body => {"order" => 0,
13 | "version" => 1,
14 | "template" => "test",
15 | "index_patterns" => "test-*",
16 | "settings" => {"number_of_shards" => "1",
17 | "number_of_replicas" => "0"}}})
18 | subject.indices.exists_template({:name => "test"}).should be_true
19 | subject.indices.delete_template({:name => "test"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/indices/exists_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesExistTest
6 | include Spec
7 |
8 | context "Indices: Exists: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "check if index exists" do
16 | subject.indices.exists({:index => "test"}).should be_false
17 | subject.indices.create({:index => "test"})
18 | subject.indices.exists({:index => "test"}).should be_true
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/exists_type_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesExistsTypeTest
6 | include Spec
7 |
8 | context "Indices: Exists Type: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "type exists" do
12 | subject.indices.exists_type({:index => "test", :type => "type_1"}).should be_false
13 | subject.indices.create({:index => "test", :body => {"mappings" => {"type_1" => {} of String => String}}})
14 | subject.indices.exists_type({:index => "test", :type => "type_1"}).should be_true
15 | subject.indices.delete({:index => "test"})
16 | end
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/test/integration/indices/flush_synced_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | # I seem to be hitting some sort of compiler bug, going to file an issue later, till then no flushing :(
4 |
5 | module Elasticsearch
6 | module Test
7 | class IndicesFlushSyncedTest
8 | include Spec
9 | context "Indices: Flush Synced Test: " do
10 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
11 |
12 | it "carry out synced flush" do
13 | subject.indices.create({:index => "test_index", :body => {"settings" => {"number_of_replicas" => "0"}}})
14 | subject.cluster.health({:wait_for_status => "green"})
15 | subject.indices.flush_synced({:index => "test"})
16 | #json_result = subject.indices.stats({:level => "shards"})
17 | #hash_result = json_result.as(JSON::Any).as_h
18 | #hash_result["indices"]["test"]["shards"][0][0]["commit"]["user_data"]["sync_id"].should be_true
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/flush_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | # I seem to be hitting some sort of compiler bug, going to file an issue later, till then no flushing :(
4 |
5 | module Elasticsearch
6 | module Test
7 | class IndicesFlushSyncedTest
8 | include Spec
9 | context "Indices: Flush Synced Test: " do
10 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
11 |
12 | it "carry out synced flush" do
13 | subject.indices.create({:index => "test_index", :body => {"settings" => {"number_of_replicas" => "0"}}})
14 | subject.cluster.health({:wait_for_status => "green"})
15 | subject.indices.flush_synced({:index => "test"})
16 | #json_result = subject.indices.stats({:level => "shards"})
17 | #hash_result = json_result.as(JSON::Any).as_h
18 | #hash_result["indices"]["test"]["shards"][0][0]["commit"]["user_data"]["sync_id"].should be_true
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/get_alias_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetAliasTest
6 | include Spec
7 |
8 | context "Indices: Get Alias: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "testind"})
13 | end
14 |
15 | it "get an alias" do
16 | subject.indices.create({:index => "testind"})
17 | subject.indices.put_alias({:index => "testind", :name => "testali"})
18 | subject.indices.get_alias({:index => "testind", :name => "testali"})
19 | subject.indices.delete_alias({:index => "testind", :name => "testali"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/indices/get_aliases_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetAliasesTest
6 | include Spec
7 |
8 | context "Indices: Get Aliases: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "testind1"})
13 | subject.indices.delete({:index => "testind2"})
14 | end
15 |
16 | it "get an alias" do
17 | subject.indices.create({:index => "testind1"})
18 | subject.indices.create({:index => "testind2"})
19 | subject.indices.put_alias({:index => "testind1", :name => "testali1"})
20 | subject.indices.put_alias({:index => "testind2", :name => "testali2"})
21 | subject.indices.get_aliases({:index => "testind1,testind2", :name => "testali1,testali2"})
22 | subject.indices.delete_alias({:index => "testind1", :name => "testali1"})
23 | subject.indices.delete_alias({:index => "testind2", :name => "testali2"})
24 | end
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/test/integration/indices/get_field_mapping_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetFieldMappingTest
6 | include Spec
7 |
8 | context "Indices: Get Field Mapping: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "get a field mapping" do
16 | subject.indices.create({:index => "test", :body => {"mappings" => {
17 | "document" => {
18 | "properties" => {
19 | "title" => {
20 | "type" => "text",
21 | "fields" => {
22 | "title" => { "type" => "text"},
23 | }
24 | }
25 | }
26 | }
27 | }}})
28 | subject.indices.get_field_mapping({:index => "test", :field => ["title"]})
29 | end
30 | end
31 | end
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/test/integration/indices/get_mapping_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetMappingTest
6 | include Spec
7 |
8 | context "Indices: Get Mapping: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "delete a mapping" do
16 | subject.indices.create({:index => "test", :body => {"mappings" => {"type_1" => {} of String => String}}})
17 | subject.indices.get_mapping({:index => "test", :type => "type_1"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/get_settings_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetSettingsTest
6 | include Spec
7 |
8 | context "Indices: Get Settings: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should create an index with settings" do
16 | subject.indices.create({:index => "test_index", :body => {"settings" => {"number_of_replicas" => "0"}}})
17 | subject.indices.get_settings({:index => "test_index"}).to_json.should match /(?=.*settings)(?=.*0)(?=.*test_index)(?=.*replicas)/
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/get_template_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetTemplateTest
6 | include Spec
7 |
8 | context "Indices: Get Template: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "template exists" do
12 | subject.indices.put_template({:name => "test", :body => {"order" => 0,
13 | "version" => 1,
14 | "template" => "test",
15 | "index_patterns" => "test-*",
16 | "settings" => {"number_of_shards" => "1",
17 | "number_of_replicas" => "0"}}})
18 | subject.indices.get_template({:name => "test"})
19 | subject.indices.delete_template({:name => "test"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/indices/get_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetTest
6 | include Spec
7 |
8 | context "Indices: Get: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test_index"})
13 | end
14 |
15 | it "should get an index with settings" do
16 | subject.indices.create({:index => "test_index", :body => {"settings" => {"number_of_replicas" => "0"}}})
17 | subject.indices.get({:index => "test_index"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/get_warmer_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesGetWarmerTest
6 | include Spec
7 |
8 | context "Indices: Get Warmer: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "get a warmer" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.put_warmer({:index => "test", :name => "main", :body => { "query" => {
18 | "filtered" => {
19 | "filter" => {
20 | "term" => { "published" => true }
21 | }
22 | }
23 | },
24 | "sort" => [ "created_at" ]
25 | }})
26 | subject.indices.get_warmer({:index => "test", :name => "main"})
27 | subject.indices.delete_warmer({:index => "test", :name => "main"})
28 | end
29 | end
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/test/integration/indices/open_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesOpenTest
6 | include Spec
7 |
8 | context "Indices: Open: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "open an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.open({:index => "test"})
18 | subject.cat.indices.as(String).should match /open/
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/optimize_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesOptimizeTest
6 | include Spec
7 |
8 | context "Indices: Optimize: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "open an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.optimize({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/put_alias_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesPutAliasTest
6 | include Spec
7 |
8 | context "Indices: Put Alias: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "testind"})
13 | end
14 |
15 | it "put an alias" do
16 | subject.indices.create({:index => "testind"})
17 | subject.indices.put_alias({:index => "testind", :name => "testali"})
18 | subject.cat.aliases.as(String).should match /testali/
19 | subject.indices.delete_alias({:index => "testind", :name => "testali"})
20 | (subject.cat.aliases.as(String).empty?).should be_true
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/test/integration/indices/put_mapping_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesPutMappingTest
6 | include Spec
7 |
8 | context "Indices: Put Mapping: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "put a mapping" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.put_mapping({:index => "test", :type => "type_1", :body => {"type_1" => {} of String => String}})
18 | subject.indices.delete_mapping({:index => "test", :type => "type_1"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/put_template_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesPutTemplateTest
6 | include Spec
7 |
8 | context "Indices: Put Template: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "put a template" do
12 | subject.indices.put_template({:name => "test", :body => {"order" => 0,
13 | "version" => 1,
14 | "template" => "test",
15 | "index_patterns" => "test-*",
16 | "settings" => {"number_of_shards" => "1",
17 | "number_of_replicas" => "0"}}})
18 | subject.indices.delete_template({:name => "test"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/indices/put_warmer_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesPutWarmerTest
6 | include Spec
7 |
8 | context "Indices: Put Warmer: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "put a warmer" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.put_warmer({:index => "test", :name => "main", :body => { "query" => {
18 | "filtered" => {
19 | "filter" => {
20 | "term" => { "published" => true }
21 | }
22 | }
23 | },
24 | "sort" => [ "created_at" ]
25 | }})
26 | subject.indices.get_warmer({:index => "test", :name => "main"})
27 | subject.indices.delete_warmer({:index => "test", :name => "main"})
28 | end
29 | end
30 | end
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/test/integration/indices/recovery_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesRecoveryTest
6 | include Spec
7 |
8 | context "Indices: Recovery: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "recover an index information" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.recovery({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/refresh_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesRefreshTest
6 | include Spec
7 |
8 | context "Indices: Refresh: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "refresh an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.refresh({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/rollover_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesRolloverTest
6 | include Spec
7 |
8 | context "Indices: Rollover: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test-000001"})
13 | subject.indices.delete({:index => "test-000002"})
14 | end
15 |
16 | it "rollover an alias" do
17 | subject.indices.put_template({:name => "test", :body => {"order" => 0,
18 | "version" => 1,
19 | "template" => "test",
20 | "index_patterns" => "test-*",
21 | "settings" => {"number_of_shards" => "1",
22 | "number_of_replicas" => "0"},
23 | "aliases" => {"testali" => {} of String => String}}})
24 | subject.indices.create({:index => "test-000001"})
25 | subject.indices.put_alias({:index => "test-000001", :name => "testali"})
26 | subject.indices.rollover({:alias => "testali", :body => { "conditions" => { "max_docs" => "0" }}})
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/test/integration/indices/seal_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesSealTest
6 | include Spec
7 |
8 | context "Indices: Seal: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "seal an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.seal({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/segments_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesSegmentsTest
6 | include Spec
7 |
8 | context "Indices: Segments: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "recover segments information" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.segments({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/shard_stores_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesShardStoresTest
6 | include Spec
7 |
8 | context "Indices: Shard Stores: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "recover shard stores information" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.shard_stores({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/shrink_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesShrinkTest
6 | include Spec
7 |
8 | context "Indices: Shrink: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "shrink an index into another one" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.shrink({:index => "test", :target => "test2"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/snapshot_index_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesSnapshotIndexTest
6 | include Spec
7 |
8 | context "Indices: SnapshotIndex: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "snapshot an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.snapshot_index({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/stats_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesStatsTest
6 | include Spec
7 |
8 | context "Indices: Stats: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "stats" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.stats({:index => "test", :level => "shards"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/status_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesStatusTest
6 | include Spec
7 |
8 | context "Indices: Status: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "status of an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.status({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/update_aliases_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesUpdateAliasesTest
6 | include Spec
7 |
8 | context "Indices: Update Aliases: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "testind"})
13 | end
14 |
15 | it "update an alias" do
16 | subject.indices.create({:index => "testind"})
17 | subject.indices.put_alias({:index => "testind", :name => "testali"})
18 | subject.cat.aliases.as(String).should match /testali/
19 | subject.indices.update_aliases({:body => {"actions" => [
20 | {"remove" => {"index" => "testind", "alias" => "testali"}},
21 | {"add" => {"index" => "testind", "alias" => "testali2"}},
22 | ]}})
23 | subject.indices.delete_alias({:index => "testind", :name => "testali2"})
24 | (subject.cat.aliases.as(String).empty?).should be_true
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/test/integration/indices/upgrade_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesUpgradeTest
6 | include Spec
7 |
8 | context "Indices: Upgrade: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "upgrade an index" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.upgrade({:index => "test"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/indices/validate_query_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IndicesValidateQueryTest
6 | include Spec
7 |
8 | context "Indices: ValidateQuery: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.indices.delete({:index => "test"})
13 | end
14 |
15 | it "validate a query" do
16 | subject.indices.create({:index => "test"})
17 | subject.indices.validate_query({:index => "test", :q => "title:foo AND body:bar"})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/ingest/delete_pipeline_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IngestDeletePipelineTest
6 | include Spec
7 |
8 | context "Ingest: Delete Pipeline: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.ingest.delete_pipeline({:id => "test"})
13 | end
14 |
15 | it "Delete a pipeline" do
16 | subject.ingest.put_pipeline({:id => "test", :body => {"description" => "describe pipeline",
17 | "processors" => [{"set" => {"field"=>"foo","value"=>"bar"}}]}})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/ingest/get_pipeline_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IngestGetPipelineTest
6 | include Spec
7 |
8 | context "Ingest: Get Pipeline: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.ingest.delete_pipeline({:id => "test"})
13 | end
14 |
15 | it "Delete a pipeline" do
16 | subject.ingest.put_pipeline({:id => "test", :body => {"description" => "describe pipeline",
17 | "processors" => [{"set" => {"field"=>"foo","value"=>"bar"}}]}})
18 | subject.ingest.get_pipeline({:id => "test"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/ingest/put_pipeline_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IngestPutPipelineTest
6 | include Spec
7 |
8 | context "Ingest: Put Pipeline: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.ingest.delete_pipeline({:id => "test"})
13 | end
14 |
15 | it "Delete a pipeline" do
16 | subject.ingest.put_pipeline({:id => "test", :body => {"description" => "describe pipeline",
17 | "processors" => [{"set" => {"field"=>"foo","value"=>"bar"}}]}})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/ingest/simulate_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class IngestSimulatePipelineTest
6 | include Spec
7 |
8 | context "Ingest: Simulate Pipeline: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.ingest.delete_pipeline({:id => "test"})
13 | end
14 |
15 | it "Delete a pipeline" do
16 | subject.ingest.simulate({:id => "test", :body => {"description" => "describe pipeline",
17 | "processors" => [{"set" => {"field"=>"foo","value"=>"bar"}}]}})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/nodes/hot_threads_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class NodesHotThreadsTest
6 | include Spec
7 |
8 | context "Nodes: Hot Threads: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get hot threads info" do
12 | subject.nodes.hot_threads({:threads => "10"})
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/nodes/info_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class NodesInfoTest
6 | include Spec
7 |
8 | context "Nodes: Info: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get node info" do
12 | subject.nodes.info({:jvm => "true"})
13 | subject.nodes.info({:metric => "http,network"})
14 | end
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/test/integration/nodes/shutdown_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class NodesShutdownTest
6 | include Spec
7 |
8 | context "Nodes: Shutdown: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Shutdown a node" do
12 | # not going to do this test, need to first spin up a new node and then shut it down
13 | #subject.nodes.shutdown({:node_id => "TestNode"})
14 | end
15 | end
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/test/integration/nodes/stats_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class NodesStatsTest
6 | include Spec
7 |
8 | context "Nodes: Stats: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Get stats info" do
12 | subject.nodes.stats({:metric => "jvm"})
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/integration/snapshot/create_repository_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotCreateRepositoryTest
6 | include Spec
7 |
8 | context "Snapshot: Create Repository: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Create Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | end
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/test/integration/snapshot/create_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotCreateTest
6 | include Spec
7 |
8 | context "Snapshot: Create : " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Create Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/snapshot/delete_repository_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotDeleteRepositoryTest
6 | include Spec
7 |
8 | context "Snapshot: Delete Repository: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "Delete Repository" do
12 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
13 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
14 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
15 | end
16 | end
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/test/integration/snapshot/delete_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotDeleteTest
6 | include Spec
7 |
8 | context "Snapshot: Delete : " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Delete Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
19 | subject.snapshot.delete({:repository => "test_cat_repo_1", :snapshot => "snap1"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/snapshot/get_repository_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotGetRepositoryTest
6 | include Spec
7 |
8 | context "Snapshot: Get Repository: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Get Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.get_repository({:repository => "test_cat_repo_1"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/snapshot/get_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotGetTest
6 | include Spec
7 |
8 | context "Snapshot: Get : " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Delete Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
19 | subject.snapshot.get({:repository => "test_cat_repo_1", :snapshot => "snap1"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/snapshot/restore_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotRestoreTest
6 | include Spec
7 |
8 | context "Snapshot: Restore : " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Restore snapshot" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
19 | subject.snapshot.restore({:repository => "test_cat_repo_1", :snapshot => "snap1"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/snapshot/status_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotStatusTest
6 | include Spec
7 |
8 | context "Snapshot: Status : " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Status of snapshot" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.create({:repository => "test_cat_repo_1", :snapshot => "snap1", :wait_for_completion => true})
19 | subject.snapshot.status({:repository => "test_cat_repo_1", :snapshot => "snap1"})
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/test/integration/snapshot/verify_repository_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class SnapshotVerifyRepositoryTest
6 | include Spec
7 |
8 | context "Snapshot: Verify Repository: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | Spec.after_each do
12 | subject.snapshot.delete_repository({:repository => "test_cat_repo_1"})
13 | end
14 |
15 | it "Verify Repository" do
16 | subject.snapshot.create_repository({:repository => "test_cat_repo_1", :body => {"type" => "fs",
17 | "settings" => {"location" => "test_cat_repo_1_loc"}}})
18 | subject.snapshot.verify_repository({:repository => "test_cat_repo_1"})
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/test/integration/tasks/list_test.cr:
--------------------------------------------------------------------------------
1 | require "../../spec_helper"
2 |
3 | module Elasticsearch
4 | module Test
5 | class TasksListTest
6 | include Spec
7 |
8 | context "Tasks: List: " do
9 | subject = Elasticsearch::Test::Client.new({:host => "localhost", :port => 9250})
10 |
11 | it "List Tasks" do
12 | subject.tasks.list
13 | end
14 | end
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/test/spec_helper.cr:
--------------------------------------------------------------------------------
1 | require "../src/elasticsearch/api"
2 | require "spec"
3 | require "json"
4 | require "yaml"
5 |
6 | module Elasticsearch
7 | module Test
8 | class Client < Elasticsearch::API::Client
9 | def initialize(@settings : Hash(Symbol, Int32 | String))
10 | super
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------