Skip to content

Commit bdb6a38

Browse files
Remove deprecated type parameter from searching request
1 parent da7c666 commit bdb6a38

File tree

4 files changed

+12
-30
lines changed

4 files changed

+12
-30
lines changed

opensearch-model/lib/opensearch/model/searching.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def initialize(klass, query_or_payload, options={})
3737
@options = options
3838

3939
__index_name = options[:index] || klass.index_name
40-
__document_type = options[:type] || klass.document_type
4140

4241
case
4342
# search query: ...
@@ -54,9 +53,9 @@ def initialize(klass, query_or_payload, options={})
5453
end
5554

5655
if body
57-
@definition = { index: __index_name, type: __document_type, body: body }.update options
56+
@definition = { index: __index_name, body: body }.update options
5857
else
59-
@definition = { index: __index_name, type: __document_type, q: q }.update options
58+
@definition = { index: __index_name, q: q }.update options
6059
end
6160
end
6261

@@ -71,7 +70,7 @@ def execute!
7170

7271
module ClassMethods
7372

74-
# Provides a `search` method for the model to easily search within an index/type
73+
# Provides a `search` method for the model to easily search within an index
7574
# corresponding to the model settings.
7675
#
7776
# @param query_or_payload [String,Hash,Object] The search request definition

opensearch-model/spec/opensearch/model/response/pagination/kaminari_spec.rb

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.document_type; 'bar'; end
5858
context 'when page is called once' do
5959

6060
let(:search_request) do
61-
{ index: index_field, from: 25, size: 25, q: '*', type: type_field}
61+
{ index: index_field, from: 25, size: 25, q: '*'}
6262
end
6363

6464
before do
@@ -75,11 +75,11 @@ def self.document_type; 'bar'; end
7575
context 'when page is called more than once' do
7676

7777
let(:search_request_one) do
78-
{ index: index_field, from: 25, size: 25, q: '*', type: type_field}
78+
{ index: index_field, from: 25, size: 25, q: '*'}
7979
end
8080

8181
let(:search_request_two) do
82-
{ index: index_field, from: 75, size: 25, q: '*', type: type_field}
82+
{ index: index_field, from: 75, size: 25, q: '*'}
8383
end
8484

8585
before do
@@ -399,10 +399,6 @@ def self.document_type; 'bar'; end
399399
ModelClass
400400
end
401401

402-
let(:type_field) do
403-
'bar'
404-
end
405-
406402
let(:index_field) do
407403
'foo'
408404
end
@@ -416,10 +412,6 @@ def self.document_type; 'bar'; end
416412
OpenSearch::Model::Multimodel.new(ModelClass)
417413
end
418414

419-
let(:type_field) do
420-
['bar']
421-
end
422-
423415
let(:index_field) do
424416
['foo']
425417
end
@@ -441,10 +433,6 @@ def self.document_type; 'bar'; end
441433
ModelClass
442434
end
443435

444-
let(:type_field) do
445-
'bar'
446-
end
447-
448436
let(:index_field) do
449437
'foo'
450438
end
@@ -458,10 +446,6 @@ def self.document_type; 'bar'; end
458446
OpenSearch::Model::Multimodel.new(ModelClass)
459447
end
460448

461-
let(:type_field) do
462-
['bar']
463-
end
464-
465449
let(:index_field) do
466450
['foo']
467451
end

opensearch-model/spec/opensearch/model/searching_search_request_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.document_type; 'bar'; end
4444
context 'when the search definition is a simple query' do
4545

4646
before do
47-
expect(client).to receive(:search).with(index: 'foo', type: 'bar', q: 'foo').and_return({})
47+
expect(client).to receive(:search).with(index: 'foo', q: 'foo').and_return({})
4848
end
4949

5050
let(:search) do
@@ -59,7 +59,7 @@ def self.document_type; 'bar'; end
5959
context 'when the search definition is a hash' do
6060

6161
before do
62-
expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: { foo: 'bar' }).and_return({})
62+
expect(client).to receive(:search).with(index: 'foo', body: { foo: 'bar' }).and_return({})
6363
end
6464

6565
let(:search) do
@@ -74,7 +74,7 @@ def self.document_type; 'bar'; end
7474
context 'when the search definition is a json string' do
7575

7676
before do
77-
expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: '{"foo":"bar"}').and_return({})
77+
expect(client).to receive(:search).with(index: 'foo', body: '{"foo":"bar"}').and_return({})
7878
end
7979

8080
let(:search) do
@@ -99,7 +99,7 @@ def to_hash; {foo: 'bar'}; end
9999
end
100100

101101
before do
102-
expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: {foo: 'bar'}).and_return({})
102+
expect(client).to receive(:search).with(index: 'foo', body: {foo: 'bar'}).and_return({})
103103
end
104104

105105
let(:search) do
@@ -114,7 +114,7 @@ def to_hash; {foo: 'bar'}; end
114114
context 'when extra options are specified' do
115115

116116
before do
117-
expect(client).to receive(:search).with(index: 'foo', type: 'bar', q: 'foo', size: 15).and_return({})
117+
expect(client).to receive(:search).with(index: 'foo', q: 'foo', size: 15).and_return({})
118118
end
119119

120120
let(:search) do

opensearch-rails/spec/instrumentation_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def self.document_type; 'bar'; end
6767
{ klass: 'DummyInstrumentationModel',
6868
name: 'Search',
6969
search: { body: query,
70-
index: 'foo',
71-
type: 'bar' } }).and_return({})
70+
index: 'foo'} }).and_return({})
7271
end
7372

7473
let(:query) do

0 commit comments

Comments
 (0)