elastic-enterprise-search 7.10.0.beta.1 → 7.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/jobs/elastic+enterprise-search-ruby+7.10.0.beta.1.yml +12 -0
- data/.ci/test-matrix.yml +2 -1
- data/.github/workflows/testing.yml +1 -1
- data/.gitignore +1 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +1 -0
- data/README.md +7 -225
- data/Rakefile +1 -24
- data/docs/guide/app-search-api.asciidoc +172 -0
- data/docs/guide/connecting.asciidoc +125 -0
- data/docs/guide/development.asciidoc +42 -0
- data/docs/guide/enterprise-search-api.asciidoc +46 -0
- data/docs/guide/index.asciidoc +17 -0
- data/docs/guide/installation.asciidoc +18 -0
- data/docs/guide/overview.asciidoc +59 -0
- data/docs/guide/workplace-search-api.asciidoc +121 -0
- data/elastic-enterprise-search.gemspec +5 -4
- data/lib/elastic/app-search/api/add_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/api_logs.rb +15 -16
- data/lib/elastic/app-search/api/count_analytics.rb +7 -5
- data/lib/elastic/app-search/api/create_curation.rb +8 -6
- data/lib/elastic/app-search/api/create_engine.rb +9 -7
- data/lib/elastic/app-search/api/create_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_curation.rb +6 -5
- data/lib/elastic/app-search/api/delete_documents.rb +7 -4
- data/lib/elastic/app-search/api/delete_engine.rb +5 -3
- data/lib/elastic/app-search/api/delete_meta_engine_source.rb +7 -4
- data/lib/elastic/app-search/api/delete_synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/documents.rb +7 -4
- data/lib/elastic/app-search/api/engine.rb +5 -3
- data/lib/elastic/app-search/api/index_documents.rb +7 -4
- data/lib/elastic/app-search/api/list_curations.rb +7 -5
- data/lib/elastic/app-search/api/list_documents.rb +7 -5
- data/lib/elastic/app-search/api/list_engines.rb +7 -5
- data/lib/elastic/app-search/api/list_synonym_sets.rb +7 -5
- data/lib/elastic/app-search/api/log_clickthrough.rb +10 -7
- data/lib/elastic/app-search/api/multi_search.rb +8 -7
- data/lib/elastic/app-search/api/put_curation.rb +9 -8
- data/lib/elastic/app-search/api/put_documents.rb +7 -4
- data/lib/elastic/app-search/api/put_schema.rb +7 -4
- data/lib/elastic/app-search/api/put_search_settings.rb +6 -3
- data/lib/elastic/app-search/api/put_synonym_set.rb +7 -7
- data/lib/elastic/app-search/api/query_suggestion.rb +8 -6
- data/lib/elastic/app-search/api/reset_search_settings.rb +5 -3
- data/lib/elastic/app-search/api/schema.rb +6 -4
- data/lib/elastic/app-search/api/search.rb +5 -3
- data/lib/elastic/app-search/api/search_settings.rb +6 -4
- data/lib/elastic/app-search/api/synonym_set.rb +6 -5
- data/lib/elastic/app-search/api/top_clicks_analytics.rb +9 -7
- data/lib/elastic/app-search/api/top_queries_analytics.rb +8 -6
- data/lib/elastic/app-search/app_search.rb +19 -2
- data/lib/elastic/enterprise-search/api/health.rb +6 -1
- data/lib/elastic/enterprise-search/api/put_read_only.rb +5 -1
- data/lib/elastic/enterprise-search/api/read_only.rb +6 -1
- data/lib/elastic/enterprise-search/api/stats.rb +6 -2
- data/lib/elastic/enterprise-search/api/version.rb +6 -1
- data/lib/elastic/enterprise-search/client.rb +15 -2
- data/lib/elastic/enterprise-search/request.rb +25 -13
- data/lib/elastic/enterprise-search/utils.rb +5 -6
- data/lib/elastic/enterprise-search/version.rb +1 -1
- data/lib/elastic/enterprise_search.rb +1 -1
- data/lib/elastic/workplace-search/api/add_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/create_analytics_event.rb +59 -0
- data/lib/elastic/workplace-search/api/create_external_identity.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_documents.rb +9 -7
- data/lib/elastic/workplace-search/api/delete_external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/external_identity.rb +10 -6
- data/lib/elastic/workplace-search/api/index_documents.rb +11 -8
- data/lib/elastic/workplace-search/api/list_external_identities.rb +11 -7
- data/lib/elastic/workplace-search/api/list_permissions.rb +11 -7
- data/lib/elastic/workplace-search/api/put_external_identity.rb +10 -9
- data/lib/elastic/workplace-search/api/put_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/remove_user_permissions.rb +10 -9
- data/lib/elastic/workplace-search/api/search.rb +19 -1
- data/lib/elastic/workplace-search/api/user_permissions.rb +10 -6
- data/lib/elastic/workplace-search/workplace_search.rb +26 -1
- data/spec/app-search/api_curations_spec.rb +97 -0
- data/spec/app-search/api_documents_spec.rb +20 -6
- data/spec/app-search/api_engines_spec.rb +4 -4
- data/{lib/generator/templates/_license.erb → spec/app-search/api_log_clickthrough_spec.rb} +18 -0
- data/spec/app-search/api_meta_engines_spec.rb +72 -0
- data/spec/app-search/api_query_suggestion_spec.rb +39 -0
- data/spec/app-search/api_schema_spec.rb +17 -3
- data/spec/app-search/api_search_settings_spec.rb +76 -0
- data/spec/app-search/api_synonyms_spec.rb +79 -0
- data/spec/app-search/client_spec.rb +20 -0
- data/spec/enterprise-search/client_spec.rb +11 -0
- data/spec/enterprise-search/request_spec.rb +22 -0
- data/spec/enterprise-search/utils_spec.rb +46 -0
- data/spec/fixtures/vcr/app_search/add_meta_engine_source.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_documents.yml +56 -0
- data/spec/fixtures/vcr/app_search/{index_documents.yml → api_index_documents.yml} +11 -10
- data/spec/fixtures/vcr/app_search/api_log_clickthrough.yml +54 -0
- data/spec/fixtures/vcr/app_search/api_put_schema.yml +109 -0
- data/spec/fixtures/vcr/app_search/api_put_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/api_query_suggestion.yml +59 -0
- data/spec/fixtures/vcr/app_search/api_reset_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/{schema.yml → api_schema.yml} +12 -11
- data/spec/fixtures/vcr/app_search/api_search_settings.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_curation.yml +113 -0
- data/spec/fixtures/vcr/{create_engine.yml → app_search/create_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/create_meta_engine.yml +56 -0
- data/spec/fixtures/vcr/app_search/create_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_curation.yml +56 -0
- data/spec/fixtures/vcr/{delete_engine.yml → app_search/delete_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/delete_meta_engine_source.yml +56 -0
- data/spec/fixtures/vcr/app_search/delete_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/get_curation.yml +56 -0
- data/spec/fixtures/vcr/{get_engine.yml → app_search/get_engine.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_curations.yml +56 -0
- data/spec/fixtures/vcr/{list_engines.yml → app_search/list_engines.yml} +0 -0
- data/spec/fixtures/vcr/app_search/list_synonym_sets.yml +56 -0
- data/spec/fixtures/vcr/app_search/multi_query_search.yml +2 -2
- data/spec/fixtures/vcr/app_search/put_curation.yml +113 -0
- data/spec/fixtures/vcr/app_search/put_synonym_set.yml +56 -0
- data/spec/fixtures/vcr/app_search/synonym_set.yml +56 -0
- data/spec/fixtures/vcr/{add_user_permissions.yml → workplace_search/add_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/{clear_user_permissions.yml → workplace_search/clear_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/create_analytics_event.yml +55 -0
- data/spec/fixtures/vcr/workplace_search/create_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{delete_documents.yml → workplace_search/delete_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/delete_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{index_documents.yml → workplace_search/index_documents.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/list_external_identities.yml +53 -0
- data/spec/fixtures/vcr/{list_permissions.yml → workplace_search/list_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/oauth_request_token.yml +57 -0
- data/spec/fixtures/vcr/workplace_search/put_external_identity.yml +53 -0
- data/spec/fixtures/vcr/{put_user_permissions.yml → workplace_search/put_user_permissions.yml} +22 -18
- data/spec/fixtures/vcr/{remove_user_permissions.yml → workplace_search/remove_user_permissions.yml} +11 -9
- data/spec/fixtures/vcr/workplace_search/retrieve_external_identity.yml +53 -0
- data/spec/fixtures/vcr/workplace_search/search_request.yml +60 -0
- data/spec/fixtures/vcr/{user_permissions_empty.yml → workplace_search/user_permissions_empty.yml} +11 -9
- data/spec/integration/enterprise_search_api_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/workplace-search/client_spec.rb +10 -2
- data/spec/workplace-search/create_analytics_event_spec.rb +59 -0
- data/spec/workplace-search/documents_spec.rb +80 -0
- data/spec/workplace-search/external_identities_spec.rb +84 -0
- data/spec/workplace-search/{api_spec.rb → permissions_spec.rb} +14 -66
- data/spec/workplace-search/search_spec.rb +53 -0
- metadata +96 -36
- data/lib/generator/documentation_helper.rb +0 -94
- data/lib/generator/endpoint_generator.rb +0 -119
- data/lib/generator/parameters_exceptions.rb +0 -40
- data/lib/generator/parameters_helper.rb +0 -144
- data/lib/generator/templates/endpoint_template.erb +0 -29
- data/lib/generator/templates/spec_template.erb +0 -1
- data/lib/generator/utils.rb +0 -70
- data/spec/fixtures/vcr/create_document.yml +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4088e21d195caeed0c05e7374d8317903d1784a71e1e21de3e7d11f0fea30b32
|
4
|
+
data.tar.gz: c6cc664ab8b1a388b49809aafeb1e5395284e33912b0864a591bd354e72dc3f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e471a1602e19cf80d8b28014d2266405cc17fb19dc1d11c5a0a290cc06199cfd9c0407f6fd946e9e28afeb83d8d48cbb2b4eb82e6e9d43942b49b8ddbaf3285
|
7
|
+
data.tar.gz: c36ecb6be8ec8d91e6827715f166119532c7e61887a300941506b79be0d1a3f666f2f8374155d671650ca97359883b1bd6af9dab47fe520f3d30294c9e62c642
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
- job:
|
3
|
+
name: elastic+enterprise-search-ruby+7.10.0.beta.1
|
4
|
+
display-name: 'elastic / enterprise-search-ruby # 7.10.0.beta.1'
|
5
|
+
description: Testing the enterprise-search-ruby 7.10.0.beta.1 branch.
|
6
|
+
junit_results: "*-junit.xml"
|
7
|
+
parameters:
|
8
|
+
- string:
|
9
|
+
name: branch_specifier
|
10
|
+
default: refs/heads/7.10.0.beta.1
|
11
|
+
description: the Git branch specifier to build (<branchName>, <tagName>,
|
12
|
+
<commitId>, etc.)
|
data/.ci/test-matrix.yml
CHANGED
data/.gitignore
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Contributing to enterprise-search-ruby
|
2
|
+
|
3
|
+
## Contributing Code Changes
|
4
|
+
|
5
|
+
1. Please make sure you have signed the [Contributor License
|
6
|
+
Agreement](http://www.elastic.co/contributor-agreement/). We are not
|
7
|
+
asking you to assign copyright to us, but to give us the right to distribute
|
8
|
+
your code without restriction. We ask this of all contributors in order to
|
9
|
+
assure our users of the origin and continuing existence of the code. You only
|
10
|
+
need to sign the CLA once.
|
11
|
+
|
12
|
+
2. Run rubocop and the test suite to ensure your changes do not break existing
|
13
|
+
code:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle exec rubocop
|
17
|
+
```
|
18
|
+
|
19
|
+
Check [Running
|
20
|
+
tests](https://github.com/elastic/enterprise-search-ruby/#run-tests) on the
|
21
|
+
README for instructions on how to run all the tests.
|
22
|
+
|
23
|
+
3. Rebase your changes. Update your local repository with the most recent code
|
24
|
+
from the main `enterprise-search-ruby` repository and rebase your branch
|
25
|
+
on top of the latest `master` branch. All of your changes will be squashed
|
26
|
+
into a single commit so don't worry about pushing multiple times.
|
27
|
+
|
28
|
+
4. Submit a pull request. Push your local changes to your forked repository
|
29
|
+
and [submit a pull request](https://github.com/elastic/enterprise-search-python/pulls)
|
30
|
+
and mention the issue number if any (`Closes #123`) Make sure that you
|
31
|
+
add or modify tests related to your changes so that CI will pass.
|
32
|
+
|
33
|
+
5. Sit back and wait. There may be some discussion on your pull request and
|
34
|
+
if changes are needed we would love to work with you to get your pull request
|
35
|
+
merged into enterprise-search-ruby.
|
36
|
+
|
37
|
+
## API Code Generation
|
38
|
+
|
39
|
+
All the API methods within
|
40
|
+
`lib/elastic/[app-search|enterprise-search|workplace-search]/api/*.rb` are
|
41
|
+
generated from an API specification that is not available publicly currently.
|
42
|
+
Because these files are generated, changes should instead be suggested in an
|
43
|
+
issue or as part of the description in your Pull Request.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,232 +4,11 @@
|
|
4
4
|
![rubocop](https://github.com/elastic/enterprise-search-ruby/workflows/rubocop/badge.svg)
|
5
5
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
|
6
6
|
|
7
|
-
|
7
|
+
Official Ruby API client for [Elastic Enterprise Search](https://www.elastic.co/enterprise-search). Use this gem to integrate App Search and Workplace Search into your Ruby code.
|
8
8
|
|
9
|
-
##
|
10
|
-
- [Installation](https://github.com/elastic/enterprise-search-ruby#installation)
|
11
|
-
- [Getting Started](https://github.com/elastic/enterprise-search-ruby#getting-started)
|
12
|
-
- [Enterprise Search](https://github.com/elastic/enterprise-search-ruby#enterprise-search)
|
13
|
-
- [Workplace Search](https://github.com/elastic/enterprise-search-ruby#workplace-search)
|
14
|
-
- [App Search](https://github.com/elastic/enterprise-search-ruby#app-search)
|
15
|
-
- [HTTP Layer](https://github.com/elastic/enterprise-search-ruby#http-layer)
|
16
|
-
- [Setting the host and port](https://github.com/elastic/enterprise-search-ruby#setting-the-host-and-port)
|
17
|
-
- [Logging](https://github.com/elastic/enterprise-search-ruby#logging)
|
18
|
-
- [Development](https://github.com/elastic/enterprise-search-ruby#development)
|
19
|
-
- [Run stack locally](https://github.com/elastic/enterprise-search-ruby#run-stack-locally)
|
20
|
-
- [Run tests](https://github.com/elastic/enterprise-search-ruby#run-tests)
|
21
|
-
- [License](https://github.com/elastic/enterprise-search-ruby#license)
|
9
|
+
## Documentation
|
22
10
|
|
23
|
-
|
24
|
-
|
25
|
-
Install the gem:
|
26
|
-
|
27
|
-
```
|
28
|
-
$ gem install elastic-enterprise-search --pre
|
29
|
-
```
|
30
|
-
|
31
|
-
Or add it to your project's Gemfile:
|
32
|
-
|
33
|
-
```
|
34
|
-
gem 'elastic-enterprise-search'
|
35
|
-
```
|
36
|
-
|
37
|
-
The version follows the Elastic Stack version so 7.10.0 is compatible with Enterprise Search released in Elastic Stack 7.10.0.
|
38
|
-
|
39
|
-
## Getting Started
|
40
|
-
|
41
|
-
### Enterprise Search
|
42
|
-
|
43
|
-
The Enterprise Search API uses basic auth with credentials from an Elasticsearch user. You can read about the API, authentication and privileges needed [on the official docs](https://www.elastic.co/guide/en/enterprise-search/current/management-apis.html).
|
44
|
-
|
45
|
-
#### Example usage:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
http_auth = {user: 'elastic', password: 'password'}
|
49
|
-
host = 'https://id.ent-search.europe-west2.gcp.elastic-cloud.com'
|
50
|
-
|
51
|
-
ent_client = Elastic::EnterpriseSearch::Client.new(host: host, http_auth: http_auth)
|
52
|
-
```
|
53
|
-
|
54
|
-
#### Health API
|
55
|
-
|
56
|
-
```ruby
|
57
|
-
> response = ent_client.health
|
58
|
-
> response.body
|
59
|
-
=> {"name"=>"...",
|
60
|
-
"version"=>{"number"=>"7.10.0", "build_hash"=>"...", "build_date"=>"..."},
|
61
|
-
"jvm"=>{...},
|
62
|
-
"filebeat"=>{...},
|
63
|
-
"system"=>{...}
|
64
|
-
}
|
65
|
-
```
|
66
|
-
|
67
|
-
#### Version API
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
> response = ent_client.version
|
71
|
-
> response.body
|
72
|
-
=> {"number"=>"7.10.0", "build_hash"=>"...", "build_date"=>"..."}
|
73
|
-
```
|
74
|
-
|
75
|
-
#### Managing Read-Only mode:
|
76
|
-
|
77
|
-
```ruby
|
78
|
-
# Set read-only flag state
|
79
|
-
ent_client.put_read_only(enabled: false)
|
80
|
-
|
81
|
-
# Get read-only flag state
|
82
|
-
ent_client.read_only
|
83
|
-
```
|
84
|
-
|
85
|
-
#### Stats API
|
86
|
-
```ruby
|
87
|
-
> ent_client.stats.body
|
88
|
-
=> {"app"=>{"pid"=>1, "start"=>"...", "end"=>"", "metrics"=>{...}},
|
89
|
-
"queues"=>{"connectors"=>{...}, "document_destroyer"=>{...}, "engine_destroyer"=>{...}, "index_adder"=>{...}, ...},
|
90
|
-
"connectors"=>{"alive"=>true, "pool"=>{...}, "job_store"=>{...}}}}
|
91
|
-
|
92
|
-
```
|
93
|
-
|
94
|
-
### Workplace Search
|
95
|
-
|
96
|
-
In your Elastic Workplace Search dashboard navigate to _Sources/Add a Shared Content Source_ and select _Custom API Source_ to create a new source. Name your source (e.g. `Enterprise Search Ruby Client`) and once it's created you'll get an `access token` and a `key`. You'll need these in the following steps.
|
97
|
-
|
98
|
-
#### Instantiation
|
99
|
-
|
100
|
-
The Workplace Search client can be accessed from an existing Enterprise Search Client, or you can initialize a new one. If you instantiate the Workplace Search client from an existing Enterprise Search Client, it's going to share the HTTP transport instance, so it's going to connect to the same host, which is a common scenario. However, if you want to connect to a different host, you should instantiate a new Workplace Client on its own:
|
101
|
-
|
102
|
-
```ruby
|
103
|
-
# Prerequisites
|
104
|
-
host = 'https://id.ent-search.europe-west2.gcp.elastic-cloud.com'
|
105
|
-
access_token = '<access token>'
|
106
|
-
content_source_key = '<content source key>'
|
107
|
-
|
108
|
-
# From the Enterprise Search client:
|
109
|
-
ent_client = Elastic::EnterpriseSearch::Client.new(host: host)
|
110
|
-
ent_client.workplace_search.http_auth = access_token
|
111
|
-
ent_client.workplace_search.index_documents(content_source_key, body: documents)
|
112
|
-
|
113
|
-
# On its own
|
114
|
-
workplace_search_client = Elastic::EnterpriseSearch::WorkplaceSearch::Client.new(
|
115
|
-
host: host,
|
116
|
-
http_auth: access_token
|
117
|
-
)
|
118
|
-
```
|
119
|
-
|
120
|
-
### App Search
|
121
|
-
|
122
|
-
In your Elastic App Search dashboard, navigate to Credentials and Create a Key for the client to use. Make sure to read [the documentation on Authentication](https://www.elastic.co/guide/en/app-search/current/authentication.html) to understand which key you want to use. Once you've created your key, you need to copy the key value to use on your client:
|
123
|
-
|
124
|
-
#### Instantiation
|
125
|
-
|
126
|
-
The App Search client can be accessed from an existing Enterprise Search Client, or you can initialize a new one. If you instantiate the App Search client from an existing Enterprise Search Client, it's going to share the HTTP transport instance, so it's going to connect to the same host which is a common scenario. However, if you want to connect to a different host, you should instantiate a new App Search Client on its own.
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
# Prerequisites
|
130
|
-
host = 'https://id.ent-search.europe-west2.gcp.elastic-cloud.com'
|
131
|
-
api_key = 'private-api-key'
|
132
|
-
|
133
|
-
# From the Enterprise Search client:
|
134
|
-
ent_client = Elastic::EnterpriseSearch::Client.new(host: host)
|
135
|
-
ent_client.app_search.http_auth = api_key
|
136
|
-
|
137
|
-
# On its own
|
138
|
-
client = Elastic::EnterpriseSearch::AppSearch::Client.new(host: host, http_auth: api_key)
|
139
|
-
```
|
140
|
-
|
141
|
-
#### Engines
|
142
|
-
|
143
|
-
```ruby
|
144
|
-
# Create an engine
|
145
|
-
client.create_engine(name: 'videogames')
|
146
|
-
|
147
|
-
# List all engines
|
148
|
-
client.list_engines
|
149
|
-
|
150
|
-
# Get an engine
|
151
|
-
client.engine('videogames')
|
152
|
-
|
153
|
-
# Delete an engine
|
154
|
-
client.delete_engine('videogames')
|
155
|
-
```
|
156
|
-
|
157
|
-
#### Documents
|
158
|
-
|
159
|
-
```ruby
|
160
|
-
engine_name = 'videogames'
|
161
|
-
document = {
|
162
|
-
id: 'Mr1064',
|
163
|
-
name: 'Super Luigi 64',
|
164
|
-
body: 'A classic 3D videogame'
|
165
|
-
}
|
166
|
-
|
167
|
-
# Index documents
|
168
|
-
client.index_documents(engine_name, body: document)
|
169
|
-
|
170
|
-
# List documents
|
171
|
-
client.list_documents(engine_name)
|
172
|
-
|
173
|
-
# Delete a document
|
174
|
-
client.delete_documents(engine_name, body: [document_id])
|
175
|
-
|
176
|
-
# Update a document
|
177
|
-
client.put_documents(engine_name, body: [{id: document_id, key: value}])
|
178
|
-
```
|
179
|
-
|
180
|
-
#### Search
|
181
|
-
|
182
|
-
```ruby
|
183
|
-
query = {
|
184
|
-
query: 'luigi'
|
185
|
-
}
|
186
|
-
|
187
|
-
client.search(engine_name, query)
|
188
|
-
```
|
189
|
-
|
190
|
-
#### Other API Endpoints
|
191
|
-
|
192
|
-
```ruby
|
193
|
-
|
194
|
-
# Count analytics - Returns the number of clicks and total number of queries over a period
|
195
|
-
client.count_analytics(engine_name)
|
196
|
-
|
197
|
-
# Schema - Retrieve current schema for the engine
|
198
|
-
client.schema(engine_name)
|
199
|
-
|
200
|
-
# Logs - The API Log displays API request and response data at the Engine level
|
201
|
-
client.api_logs(engine_name, from_date: Date.new(2020, 10, 01), to_date: Date.new(2020, 11, 05))
|
202
|
-
|
203
|
-
# Queries Analytics - Returns queries analytics by usage count
|
204
|
-
client.top_queries_analytics(engine_name)
|
205
|
-
|
206
|
-
# Clicks Analytics - Returns the number of clicks received by a document in descending order
|
207
|
-
client.top_clicks_analytics(engine_name, query: {})
|
208
|
-
|
209
|
-
```
|
210
|
-
|
211
|
-
## HTTP Layer
|
212
|
-
|
213
|
-
This library uses [elasticsearch-transport](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-transport), the low-level Ruby client for connecting to an Elasticsearch cluster - also used in the official [Elasticsearch Ruby Client](https://github.com/elastic/elasticsearch-ruby).
|
214
|
-
|
215
|
-
All requests, if successful, will return an `Elasticsearch::Transport::Transport::Response` instance. You can access the response `body`, `headers` and `status`.
|
216
|
-
|
217
|
-
`elasticsearch-transport` defines a [number of exception classes](https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-transport/lib/elasticsearch/transport/transport/errors.rb) for various client and server errors, as well as unsuccessful HTTP responses, making it possible to rescue specific exceptions with desired granularity. More details [here](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-transport#exception-handling). You can find the full documentation for `elasticsearch-transport` at [RubyDoc](https://rubydoc.info/gems/elasticsearch-transport).
|
218
|
-
|
219
|
-
The clients pass different options to transport, you can check them out [in the source code](https://github.com/elastic/enterprise-search-ruby/blob/master/lib/elastic/enterprise-search/client.rb) while we set up RubyDocs.
|
220
|
-
|
221
|
-
### Setting the host and port
|
222
|
-
|
223
|
-
If you don't specify a host and port, the client will default to `http://localhost:3002`. Otherwise pass in the `:host` parameter as a String.
|
224
|
-
|
225
|
-
### Logging
|
226
|
-
|
227
|
-
You can enable logging with the default logger by passing `log: true` as a parameter to the client's initializer, or pass in a Logger object with the `:logger` parameter:
|
228
|
-
|
229
|
-
```ruby
|
230
|
-
logger = MyLogger.new
|
231
|
-
client = Elastic::EnterpriseSearch::Client.new(logger: logger)
|
232
|
-
```
|
11
|
+
[See the documentation](https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/index.html) for compatibility info, configuring, and an API reference.
|
233
12
|
|
234
13
|
## Development
|
235
14
|
|
@@ -245,7 +24,9 @@ This will run Elastic Enterprise Search in http://localhost:3002
|
|
245
24
|
- Username: `enterprise_search`
|
246
25
|
- Password: `changeme`
|
247
26
|
|
248
|
-
|
27
|
+
The version of the Elastic Enterprise Search Stack to use should be the same as tags of `https://www.docker.elastic.co/r/enterprise-search`. You can also use SNAPSHOT builds such as `8.0.0-SNAPSHOT`, `7.11-SNAPSHOT`, etc.
|
28
|
+
|
29
|
+
### Running Tests
|
249
30
|
|
250
31
|
Unit tests for the clients:
|
251
32
|
|
@@ -254,6 +35,7 @@ $ rake spec:client
|
|
254
35
|
```
|
255
36
|
|
256
37
|
Integration tests: you need to have an instance of Enterprise Search running either locally or remotely, and specify the host and credentials in environment variables (see below for a complete dockerized setup). If you're using the included rake task `rake stack[:version]`, you can run the integration tests with the following command:
|
38
|
+
|
257
39
|
```
|
258
40
|
$ ELASTIC_ENTERPRISE_HOST='http://localhost:3002' \
|
259
41
|
ELASTIC_ENTERPRISE_USER='elastic' \
|
data/Rakefile
CHANGED
@@ -18,30 +18,7 @@
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
20
|
require 'rspec/core/rake_task'
|
21
|
-
|
22
|
-
|
23
|
-
SPECS = [:workplace, :enterprise, :app].freeze
|
24
|
-
|
25
|
-
desc 'Generate code from JSON API spec - rake generate[wokplace||enterprise||app]'
|
26
|
-
task :generate, [:files] do |_, params|
|
27
|
-
if params[:files].nil?
|
28
|
-
SPECS.each do |spec|
|
29
|
-
generate_specs(spec)
|
30
|
-
end
|
31
|
-
else
|
32
|
-
params[:files].split(' ').each do |arg|
|
33
|
-
unless SPECS.include?(arg.to_sym)
|
34
|
-
raise "Available parameters are #{SPECS.map(&:to_s).join(', ')}. No spec for #{arg}"
|
35
|
-
end
|
36
|
-
|
37
|
-
generate_specs(arg)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def generate_specs(name)
|
43
|
-
Elastic::Generator::EndpointGenerator.new(name.to_sym).generate
|
44
|
-
end
|
21
|
+
require 'bundler/gem_tasks'
|
45
22
|
|
46
23
|
desc 'Open an irb session preloaded with this library'
|
47
24
|
task :console do
|
@@ -0,0 +1,172 @@
|
|
1
|
+
[[app-search-api]]
|
2
|
+
== App Search API
|
3
|
+
|
4
|
+
=== Engines
|
5
|
+
|
6
|
+
[source,rb]
|
7
|
+
----------------------------
|
8
|
+
# Create an engine
|
9
|
+
client.create_engine(name: 'videogames')
|
10
|
+
|
11
|
+
# List all engines
|
12
|
+
client.list_engines
|
13
|
+
|
14
|
+
# Get an engine
|
15
|
+
client.engine('videogames')
|
16
|
+
|
17
|
+
# Delete an engine
|
18
|
+
client.delete_engine('videogames')
|
19
|
+
----------------------------
|
20
|
+
|
21
|
+
=== Meta engines
|
22
|
+
|
23
|
+
[source,rb]
|
24
|
+
----------------------------
|
25
|
+
# Create a meta engine:
|
26
|
+
body = {
|
27
|
+
name: engine_name,
|
28
|
+
type: 'meta',
|
29
|
+
source_engines: [ 'books', 'videogames' ]
|
30
|
+
}
|
31
|
+
client.create_engine(name: engine_name, body: body)
|
32
|
+
|
33
|
+
# Add a source engine to a meta engine:
|
34
|
+
client.add_meta_engine_source(meta_engine_name, source_engines: ['engine1', 'engine2'])
|
35
|
+
|
36
|
+
# Remove a source enginge from a meta engine:
|
37
|
+
client.delete_meta_engine_source(meta_engine_name, source_engines: ['engine1', 'engine2'])
|
38
|
+
----------------------------
|
39
|
+
|
40
|
+
=== Documents
|
41
|
+
|
42
|
+
[source,rb]
|
43
|
+
----------------------------
|
44
|
+
engine_name = 'videogames'
|
45
|
+
document = {
|
46
|
+
id: 'Mr1064',
|
47
|
+
name: 'Super Luigi 64',
|
48
|
+
body: 'A classic 3D videogame'
|
49
|
+
}
|
50
|
+
|
51
|
+
# Index documents
|
52
|
+
client.index_documents(engine_name, documents: document)
|
53
|
+
|
54
|
+
# List documents
|
55
|
+
client.list_documents(engine_name)
|
56
|
+
|
57
|
+
# Get document(s) by ID:
|
58
|
+
client.documents(engine_name, document_ids: [id1, id2])
|
59
|
+
|
60
|
+
# Delete a document
|
61
|
+
client.delete_documents(engine_name, document_ids: [document_id])
|
62
|
+
|
63
|
+
# Update a document
|
64
|
+
client.put_documents(engine_name, documents: [{id: document_id, key: value}])
|
65
|
+
----------------------------
|
66
|
+
|
67
|
+
=== Search
|
68
|
+
|
69
|
+
[source,rb]
|
70
|
+
----------------------------
|
71
|
+
# Single Search
|
72
|
+
query = {
|
73
|
+
query: 'luigi'
|
74
|
+
}
|
75
|
+
|
76
|
+
client.search(engine_name, query)
|
77
|
+
|
78
|
+
# Multi query search
|
79
|
+
queries = [{ query: 'Nicanor'}, { query: 'Iain' }]
|
80
|
+
|
81
|
+
client.multi_search(engine_name, queries: queries)
|
82
|
+
----------------------------
|
83
|
+
|
84
|
+
=== Synonym Sets
|
85
|
+
|
86
|
+
[source,rb]
|
87
|
+
----------------------------
|
88
|
+
# Create a synonym set
|
89
|
+
client.create_synonym_set(engine_name, body: {['synonym1', 'synonym2']})
|
90
|
+
|
91
|
+
# List synonym sets
|
92
|
+
client.list_synonym_sets(engine_name)
|
93
|
+
|
94
|
+
# Retrieve a synonym set by id
|
95
|
+
client.synonym_set(engine_name, synonym_set_id: 'id')
|
96
|
+
|
97
|
+
# Update a synonym set by id
|
98
|
+
client.put_synonym_set(engine_name, synonym_set_id: 'id', body: {synonyms: ['synonym2', 'synonym3']})
|
99
|
+
|
100
|
+
# Delete a synonym set
|
101
|
+
client.delete_synonym_set(engine_name, synonym_set_id: id)
|
102
|
+
----------------------------
|
103
|
+
|
104
|
+
=== Curations
|
105
|
+
|
106
|
+
[source,rb]
|
107
|
+
----------------------------
|
108
|
+
# Create a curation
|
109
|
+
client.create_curation(
|
110
|
+
engine_name,
|
111
|
+
queries: ['query1'],
|
112
|
+
promoted: ['doc-id1'],
|
113
|
+
hidden: ['doc-id2']
|
114
|
+
)
|
115
|
+
|
116
|
+
# Retrieve a curation by id:
|
117
|
+
client.curation(engine_name, curation_id: 'cur-id')
|
118
|
+
|
119
|
+
# Update an existing curation:
|
120
|
+
client.put_curation(
|
121
|
+
engine_name,
|
122
|
+
curation_id: 'cur-id',
|
123
|
+
queries: ['query1'],
|
124
|
+
promoted: ['doc-id2'],
|
125
|
+
hidden: ['doc-id1']
|
126
|
+
)
|
127
|
+
|
128
|
+
# List existing curations:
|
129
|
+
client.list_curations(engine_name)
|
130
|
+
|
131
|
+
# Delete a curation:
|
132
|
+
client.delete_curation(engine_name, curation_id: 'cur-id')
|
133
|
+
----------------------------
|
134
|
+
|
135
|
+
=== Other API Endpoints
|
136
|
+
|
137
|
+
[source,rb]
|
138
|
+
----------------------------
|
139
|
+
# Count analytics - Returns the number of clicks and total number of queries over a period
|
140
|
+
client.count_analytics(engine_name)
|
141
|
+
|
142
|
+
# Schema - Retrieve current schema for the engine
|
143
|
+
client.schema(engine_name)
|
144
|
+
|
145
|
+
# Update schema for an engine
|
146
|
+
client.put_schema(engine_name, schema: {field: 'type'})
|
147
|
+
|
148
|
+
# Logs - The API Log displays API request and response data at the Engine level
|
149
|
+
client.api_logs(engine_name, from_date: Date.new(2020, 10, 01), to_date: Date.new(2020, 11, 05))
|
150
|
+
|
151
|
+
# Queries Analytics - Returns queries analytics by usage count
|
152
|
+
client.top_queries_analytics(engine_name)
|
153
|
+
|
154
|
+
# Clicks Analytics - Returns the number of clicks received by a document in descending order
|
155
|
+
client.top_clicks_analytics(engine_name, query: {})
|
156
|
+
|
157
|
+
# Search Settings - Returns current search settings for an engine
|
158
|
+
client.search_settings(engine_name)
|
159
|
+
|
160
|
+
# Update Search Settings
|
161
|
+
client.put_search_settings(engine_name, body: body)
|
162
|
+
|
163
|
+
# Reset search settings
|
164
|
+
# Warning: This means your settings are wiped! Back them up!
|
165
|
+
client.reset_search_settings(engine_name)
|
166
|
+
|
167
|
+
# Click - Send data about clicked results
|
168
|
+
client.log_clickthrough(engine_name, query_text: 'query', document_id: 'doc-id')
|
169
|
+
|
170
|
+
# Query Suggestion - Provide relevant query suggestions for incomplete queries
|
171
|
+
client.query_suggestion(engine_name, query: 'incomplete_query')
|
172
|
+
----------------------------
|