manticore-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.openapi-generator/FILES +149 -0
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.openapi-generator-ignore +5 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +160 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +103 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +136 -0
  12. data/Rakefile +10 -0
  13. data/docs/AggComposite.md +20 -0
  14. data/docs/AggCompositeSource.md +18 -0
  15. data/docs/AggCompositeTerm.md +18 -0
  16. data/docs/AggTerms.md +20 -0
  17. data/docs/Aggregation.md +22 -0
  18. data/docs/AutocompleteRequest.md +22 -0
  19. data/docs/BoolFilter.md +22 -0
  20. data/docs/BulkResponse.md +26 -0
  21. data/docs/DeleteDocumentRequest.md +24 -0
  22. data/docs/DeleteResponse.md +26 -0
  23. data/docs/ErrorResponse.md +20 -0
  24. data/docs/FulltextFilter.md +24 -0
  25. data/docs/GeoDistance.md +24 -0
  26. data/docs/GeoDistanceLocationAnchor.md +20 -0
  27. data/docs/Highlight.md +62 -0
  28. data/docs/HighlightAllOfFields.md +15 -0
  29. data/docs/HighlightFieldOption.md +26 -0
  30. data/docs/HitsHits.md +22 -0
  31. data/docs/IndexApi.md +401 -0
  32. data/docs/InsertDocumentRequest.md +24 -0
  33. data/docs/Join.md +24 -0
  34. data/docs/JoinCond.md +22 -0
  35. data/docs/JoinOn.md +22 -0
  36. data/docs/KnnQuery.md +28 -0
  37. data/docs/Match.md +22 -0
  38. data/docs/MatchAll.md +18 -0
  39. data/docs/PercolateRequest.md +18 -0
  40. data/docs/PercolateRequestQuery.md +18 -0
  41. data/docs/QueryFilter.md +34 -0
  42. data/docs/Range.md +24 -0
  43. data/docs/ReplaceDocumentRequest.md +18 -0
  44. data/docs/ResponseError.md +49 -0
  45. data/docs/ResponseErrorDetails.md +22 -0
  46. data/docs/SearchApi.md +204 -0
  47. data/docs/SearchQuery.md +36 -0
  48. data/docs/SearchRequest.md +46 -0
  49. data/docs/SearchResponse.md +30 -0
  50. data/docs/SearchResponseHits.md +24 -0
  51. data/docs/SourceRules.md +20 -0
  52. data/docs/SqlResponse.md +49 -0
  53. data/docs/SuccessResponse.md +28 -0
  54. data/docs/UpdateDocumentRequest.md +26 -0
  55. data/docs/UpdateResponse.md +24 -0
  56. data/docs/UtilsApi.md +76 -0
  57. data/lib/manticore/client/api/index_api.rb +442 -0
  58. data/lib/manticore/client/api/search_api.rb +232 -0
  59. data/lib/manticore/client/api/utils_api.rb +93 -0
  60. data/lib/manticore/client/api_client.rb +437 -0
  61. data/lib/manticore/client/api_error.rb +58 -0
  62. data/lib/manticore/client/configuration.rb +385 -0
  63. data/lib/manticore/client/models/agg_composite.rb +233 -0
  64. data/lib/manticore/client/models/agg_composite_source.rb +238 -0
  65. data/lib/manticore/client/models/agg_composite_term.rb +239 -0
  66. data/lib/manticore/client/models/agg_terms.rb +249 -0
  67. data/lib/manticore/client/models/aggregation.rb +240 -0
  68. data/lib/manticore/client/models/autocomplete_request.rb +276 -0
  69. data/lib/manticore/client/models/bool_filter.rb +247 -0
  70. data/lib/manticore/client/models/bulk_response.rb +264 -0
  71. data/lib/manticore/client/models/delete_document_request.rb +269 -0
  72. data/lib/manticore/client/models/delete_response.rb +262 -0
  73. data/lib/manticore/client/models/error_response.rb +250 -0
  74. data/lib/manticore/client/models/fulltext_filter.rb +252 -0
  75. data/lib/manticore/client/models/geo_distance.rb +306 -0
  76. data/lib/manticore/client/models/geo_distance_location_anchor.rb +232 -0
  77. data/lib/manticore/client/models/highlight.rb +525 -0
  78. data/lib/manticore/client/models/highlight_all_of_fields.rb +105 -0
  79. data/lib/manticore/client/models/highlight_field_option.rb +262 -0
  80. data/lib/manticore/client/models/hits_hits.rb +242 -0
  81. data/lib/manticore/client/models/insert_document_request.rb +286 -0
  82. data/lib/manticore/client/models/join.rb +327 -0
  83. data/lib/manticore/client/models/join_cond.rb +276 -0
  84. data/lib/manticore/client/models/join_on.rb +272 -0
  85. data/lib/manticore/client/models/knn_query.rb +307 -0
  86. data/lib/manticore/client/models/match.rb +290 -0
  87. data/lib/manticore/client/models/match_all.rb +262 -0
  88. data/lib/manticore/client/models/percolate_request.rb +238 -0
  89. data/lib/manticore/client/models/percolate_request_query.rb +238 -0
  90. data/lib/manticore/client/models/query_filter.rb +307 -0
  91. data/lib/manticore/client/models/range.rb +252 -0
  92. data/lib/manticore/client/models/replace_document_request.rb +239 -0
  93. data/lib/manticore/client/models/response_error.rb +105 -0
  94. data/lib/manticore/client/models/response_error_details.rb +261 -0
  95. data/lib/manticore/client/models/search_query.rb +316 -0
  96. data/lib/manticore/client/models/search_request.rb +382 -0
  97. data/lib/manticore/client/models/search_response.rb +281 -0
  98. data/lib/manticore/client/models/search_response_hits.rb +254 -0
  99. data/lib/manticore/client/models/source_rules.rb +236 -0
  100. data/lib/manticore/client/models/sql_response.rb +106 -0
  101. data/lib/manticore/client/models/success_response.rb +272 -0
  102. data/lib/manticore/client/models/update_document_request.rb +296 -0
  103. data/lib/manticore/client/models/update_response.rb +252 -0
  104. data/lib/manticore/client/version.rb +7 -0
  105. data/lib/manticore/client.rb +32 -0
  106. data/lib/manticore-client.rb +3 -0
  107. data/manticore-client.gemspec +34 -0
  108. data/spec/api/index_api_spec.rb +179 -0
  109. data/spec/api/search_api_spec.rb +94 -0
  110. data/spec/api/utils_api_spec.rb +100 -0
  111. data/spec/spec_helper.rb +92 -0
  112. data/spec/support/manticore_sql_helper.rb +33 -0
  113. metadata +218 -0
@@ -0,0 +1,92 @@
1
+ require "manticore/client"
2
+ require "uri"
3
+ require "json"
4
+ require "net/http"
5
+ require "pry"
6
+ require_relative "support/manticore_sql_helper"
7
+
8
+ # Table prefix for all test indexes; configurable via ENV
9
+ TABLE_PREFIX = ENV["MANTICORE_TEST_PREFIX"] || "test_"
10
+
11
+ # Configure Manticore::Client from MANTICORESEARCH_URI or default
12
+ uri = ENV["MANTICORESEARCH_URI"] || "http://127.0.0.1:9308"
13
+ parsed = URI.parse(uri)
14
+
15
+ unless parsed.host && parsed.port
16
+ abort "\n[ERROR] MANTICORESEARCH_URI must specify a valid host and port. Got: #{uri}\n"
17
+ end
18
+
19
+ Manticore::Client.configure do |config|
20
+ config.host = "#{parsed.scheme}://#{parsed.host}:#{parsed.port}"
21
+ config.username = parsed.user if parsed.user
22
+ config.password = parsed.password if parsed.password
23
+ config.debugging = ENV["DEBUG"] == "true"
24
+ end
25
+
26
+ # Optionally, check if the server is available before running specs
27
+ begin
28
+ Net::HTTP.start(parsed.host, parsed.port, read_timeout: 2) do |http|
29
+ http.head("/")
30
+ end
31
+ rescue StandardError => e
32
+ abort "\n[ERROR] Could not connect to ManticoreSearch at #{parsed.host}:#{parsed.port}. " \
33
+ "Is it running? (#{e.class}: #{e.message})\n"
34
+ end
35
+
36
+ RSpec.configure do |config|
37
+ config.before(:suite) do
38
+ ManticoreSqlHelper.tables(prefix: TABLE_PREFIX).each do |table|
39
+ ManticoreSqlHelper.drop_table(table)
40
+ end
41
+ end
42
+
43
+ config.after(:suite) do
44
+ ManticoreSqlHelper.tables(prefix: TABLE_PREFIX).each do |table|
45
+ ManticoreSqlHelper.drop_table(table)
46
+ end
47
+ end
48
+
49
+ config.expect_with :rspec do |expectations|
50
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
51
+ end
52
+
53
+ config.mock_with :rspec do |mocks|
54
+ mocks.verify_partial_doubles = true
55
+ end
56
+
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+ config.example_status_persistence_file_path = "spec/examples.txt"
60
+ config.disable_monkey_patching!
61
+ config.warnings = true
62
+
63
+ config.default_formatter = "doc" if config.files_to_run.one?
64
+
65
+ config.profile_examples = 10
66
+ config.order = :random
67
+ Kernel.srand config.seed
68
+ end
69
+
70
+ # Helper method to check if docs exist in a table
71
+ # This matcher checks if the table contains the expected documents
72
+ # It queries the table and compares the results with the expected documents
73
+ # If the table does not exist or if there are no matching documents, it raises an error
74
+ # Usage:
75
+ # expect(TABLE_PREFIX + "movies").to have_docs(
76
+ # { id: 1, title: "Scary movie", rating: 9.5 },
77
+ # { id: 3, title: "New movie", rating: 8.5 }
78
+ # )
79
+ RSpec::Matchers.define :have_docs do |expected|
80
+ match do |actual|
81
+ result = ManticoreSqlHelper.query("SELECT * FROM #{actual}")
82
+ result.any? { |row| row >= expected }
83
+ end
84
+
85
+ failure_message do |actual|
86
+ "expected that table #{actual} would have #{expected} rows, but it has #{actual.count}"
87
+ end
88
+
89
+ failure_message_when_negated do |actual|
90
+ "expected that table #{actual} would not have #{expected} rows, but it does"
91
+ end
92
+ end
@@ -0,0 +1,33 @@
1
+ module ManticoreSqlHelper
2
+ QueryError = Class.new(StandardError) do
3
+ attr_reader :sql, :error
4
+
5
+ def initialize(error, sql)
6
+ @sql = sql
7
+ @error = error
8
+ super("SQL query failed: #{sql}\n#{error}")
9
+ end
10
+ end
11
+
12
+ def self.client
13
+ @client ||= Manticore::Client::UtilsApi.new
14
+ end
15
+
16
+ def self.query(sql)
17
+ sql_encoded = URI.encode_www_form_component(sql)
18
+ response = client.sql("query=#{sql_encoded}", query_params: { mode: "raw" }).first
19
+ raise QueryError.new(response[:error], sql) unless response[:error].empty?
20
+
21
+ response[:data]
22
+ end
23
+
24
+ def self.tables(prefix: nil)
25
+ res = query("SHOW TABLES")
26
+ tables = res.map { |row| row[:Table] }
27
+ prefix ? tables.select { |t| t.start_with?(prefix) } : tables
28
+ end
29
+
30
+ def self.drop_table(name)
31
+ query("DROP TABLE #{name}")
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: manticore-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - OpenAPI-Generator
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.0.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 1.0.1
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: faraday-multipart
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: marcel
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: zeitwerk
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ description: 'Сlient for Manticore Search. '
75
+ email:
76
+ - subbota@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".openapi-generator-ignore"
83
+ - ".openapi-generator/FILES"
84
+ - ".openapi-generator/VERSION"
85
+ - ".rspec"
86
+ - ".rubocop.yml"
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - docs/AggComposite.md
93
+ - docs/AggCompositeSource.md
94
+ - docs/AggCompositeTerm.md
95
+ - docs/AggTerms.md
96
+ - docs/Aggregation.md
97
+ - docs/AutocompleteRequest.md
98
+ - docs/BoolFilter.md
99
+ - docs/BulkResponse.md
100
+ - docs/DeleteDocumentRequest.md
101
+ - docs/DeleteResponse.md
102
+ - docs/ErrorResponse.md
103
+ - docs/FulltextFilter.md
104
+ - docs/GeoDistance.md
105
+ - docs/GeoDistanceLocationAnchor.md
106
+ - docs/Highlight.md
107
+ - docs/HighlightAllOfFields.md
108
+ - docs/HighlightFieldOption.md
109
+ - docs/HitsHits.md
110
+ - docs/IndexApi.md
111
+ - docs/InsertDocumentRequest.md
112
+ - docs/Join.md
113
+ - docs/JoinCond.md
114
+ - docs/JoinOn.md
115
+ - docs/KnnQuery.md
116
+ - docs/Match.md
117
+ - docs/MatchAll.md
118
+ - docs/PercolateRequest.md
119
+ - docs/PercolateRequestQuery.md
120
+ - docs/QueryFilter.md
121
+ - docs/Range.md
122
+ - docs/ReplaceDocumentRequest.md
123
+ - docs/ResponseError.md
124
+ - docs/ResponseErrorDetails.md
125
+ - docs/SearchApi.md
126
+ - docs/SearchQuery.md
127
+ - docs/SearchRequest.md
128
+ - docs/SearchResponse.md
129
+ - docs/SearchResponseHits.md
130
+ - docs/SourceRules.md
131
+ - docs/SqlResponse.md
132
+ - docs/SuccessResponse.md
133
+ - docs/UpdateDocumentRequest.md
134
+ - docs/UpdateResponse.md
135
+ - docs/UtilsApi.md
136
+ - lib/manticore-client.rb
137
+ - lib/manticore/client.rb
138
+ - lib/manticore/client/api/index_api.rb
139
+ - lib/manticore/client/api/search_api.rb
140
+ - lib/manticore/client/api/utils_api.rb
141
+ - lib/manticore/client/api_client.rb
142
+ - lib/manticore/client/api_error.rb
143
+ - lib/manticore/client/configuration.rb
144
+ - lib/manticore/client/models/agg_composite.rb
145
+ - lib/manticore/client/models/agg_composite_source.rb
146
+ - lib/manticore/client/models/agg_composite_term.rb
147
+ - lib/manticore/client/models/agg_terms.rb
148
+ - lib/manticore/client/models/aggregation.rb
149
+ - lib/manticore/client/models/autocomplete_request.rb
150
+ - lib/manticore/client/models/bool_filter.rb
151
+ - lib/manticore/client/models/bulk_response.rb
152
+ - lib/manticore/client/models/delete_document_request.rb
153
+ - lib/manticore/client/models/delete_response.rb
154
+ - lib/manticore/client/models/error_response.rb
155
+ - lib/manticore/client/models/fulltext_filter.rb
156
+ - lib/manticore/client/models/geo_distance.rb
157
+ - lib/manticore/client/models/geo_distance_location_anchor.rb
158
+ - lib/manticore/client/models/highlight.rb
159
+ - lib/manticore/client/models/highlight_all_of_fields.rb
160
+ - lib/manticore/client/models/highlight_field_option.rb
161
+ - lib/manticore/client/models/hits_hits.rb
162
+ - lib/manticore/client/models/insert_document_request.rb
163
+ - lib/manticore/client/models/join.rb
164
+ - lib/manticore/client/models/join_cond.rb
165
+ - lib/manticore/client/models/join_on.rb
166
+ - lib/manticore/client/models/knn_query.rb
167
+ - lib/manticore/client/models/match.rb
168
+ - lib/manticore/client/models/match_all.rb
169
+ - lib/manticore/client/models/percolate_request.rb
170
+ - lib/manticore/client/models/percolate_request_query.rb
171
+ - lib/manticore/client/models/query_filter.rb
172
+ - lib/manticore/client/models/range.rb
173
+ - lib/manticore/client/models/replace_document_request.rb
174
+ - lib/manticore/client/models/response_error.rb
175
+ - lib/manticore/client/models/response_error_details.rb
176
+ - lib/manticore/client/models/search_query.rb
177
+ - lib/manticore/client/models/search_request.rb
178
+ - lib/manticore/client/models/search_response.rb
179
+ - lib/manticore/client/models/search_response_hits.rb
180
+ - lib/manticore/client/models/source_rules.rb
181
+ - lib/manticore/client/models/sql_response.rb
182
+ - lib/manticore/client/models/success_response.rb
183
+ - lib/manticore/client/models/update_document_request.rb
184
+ - lib/manticore/client/models/update_response.rb
185
+ - lib/manticore/client/version.rb
186
+ - manticore-client.gemspec
187
+ - spec/api/index_api_spec.rb
188
+ - spec/api/search_api_spec.rb
189
+ - spec/api/utils_api_spec.rb
190
+ - spec/spec_helper.rb
191
+ - spec/support/manticore_sql_helper.rb
192
+ homepage: https://github.com/numbata/manticore-client
193
+ licenses:
194
+ - MIT
195
+ metadata:
196
+ bug_tracker_uri: https://github.com/numbata/manticore-client/issues
197
+ changelog_uri: https://github.com/numbata/manticore-client/blob/v1.0.0/CHANGELOG.md
198
+ homepage_uri: https://github.com/numbata/manticore-client
199
+ source_code_uri: https://github.com/numbata/manticore-client
200
+ rubygems_mfa_required: 'true'
201
+ rdoc_options: []
202
+ require_paths:
203
+ - lib
204
+ required_ruby_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '2.7'
209
+ required_rubygems_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ requirements: []
215
+ rubygems_version: 3.6.8
216
+ specification_version: 4
217
+ summary: Autogenerated Manticore Search client
218
+ test_files: []