-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #723 from trade-tariff/HOTT-1865-backend-tweaks-to…
…-search HOTT-1865: Fix several issues with search
- Loading branch information
Showing
14 changed files
with
191 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/serializers/api/beta/goods_nomenclature_query_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Api | ||
module Beta | ||
class GoodsNomenclatureQuerySerializer | ||
include JSONAPI::Serializer | ||
set_type :goods_nomenclature_query | ||
|
||
attributes :query | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
spec/serializers/api/beta/goods_nomenclature_query_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
RSpec.describe Api::Beta::GoodsNomenclatureQuerySerializer do | ||
describe '#serializable_hash' do | ||
subject(:serializable_hash) { described_class.new(serializable).serializable_hash } | ||
|
||
let(:serializable) { build(:goods_nomenclature_query, :full_query) } | ||
|
||
let(:expected) do | ||
{ | ||
data: { | ||
id: 'cbbc8118105b8e1c3cb4bb74a978fa83', | ||
type: :goods_nomenclature_query, | ||
attributes: { | ||
query: { | ||
size: '10', | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
multi_match: { | ||
query: 'man', | ||
fuzziness: 0.1, | ||
prefix_length: 2, | ||
tie_breaker: 0.3, | ||
type: 'best_fields', | ||
fields: [ | ||
'search_references^12', | ||
'ancestor_1_description_indexed^10', | ||
'ancestor_2_description_indexed^8', | ||
'description_indexed^6', | ||
'ancestor_3_description_indexed^4', | ||
'ancestor_4_description_indexed^4', | ||
'ancestor_5_description_indexed^4', | ||
'ancestor_6_description_indexed^4', | ||
'ancestor_7_description_indexed^4', | ||
'ancestor_8_description_indexed^4', | ||
'ancestor_9_description_indexed^4', | ||
'ancestor_10_description_indexed^4', | ||
'ancestor_11_description_indexed^4', | ||
'ancestor_12_description_indexed^4', | ||
'ancestor_13_description_indexed^4', | ||
'goods_nomenclature_item_id', | ||
], | ||
}, | ||
}, | ||
], | ||
should: [ | ||
{ | ||
multi_match: { | ||
query: 'run', | ||
fuzziness: 0.1, | ||
prefix_length: 2, | ||
tie_breaker: 0.3, | ||
type: 'best_fields', | ||
fields: [ | ||
'search_references^12', | ||
'ancestor_1_description_indexed^10', | ||
'ancestor_2_description_indexed^8', | ||
'description_indexed^6', | ||
'ancestor_3_description_indexed^4', | ||
'ancestor_4_description_indexed^4', | ||
'ancestor_5_description_indexed^4', | ||
'ancestor_6_description_indexed^4', | ||
'ancestor_7_description_indexed^4', | ||
'ancestor_8_description_indexed^4', | ||
'ancestor_9_description_indexed^4', | ||
'ancestor_10_description_indexed^4', | ||
'ancestor_11_description_indexed^4', | ||
'ancestor_12_description_indexed^4', | ||
'ancestor_13_description_indexed^4', | ||
'goods_nomenclature_item_id', | ||
], | ||
}, | ||
}, | ||
{ | ||
multi_match: { | ||
query: 'tall', | ||
fuzziness: 0.1, | ||
prefix_length: 2, | ||
tie_breaker: 0.3, | ||
type: 'best_fields', | ||
fields: [ | ||
'search_references^12', | ||
'ancestor_1_description_indexed^10', | ||
'ancestor_2_description_indexed^8', | ||
'description_indexed^6', | ||
'ancestor_3_description_indexed^4', | ||
'ancestor_4_description_indexed^4', | ||
'ancestor_5_description_indexed^4', | ||
'ancestor_6_description_indexed^4', | ||
'ancestor_7_description_indexed^4', | ||
'ancestor_8_description_indexed^4', | ||
'ancestor_9_description_indexed^4', | ||
'ancestor_10_description_indexed^4', | ||
'ancestor_11_description_indexed^4', | ||
'ancestor_12_description_indexed^4', | ||
'ancestor_13_description_indexed^4', | ||
'goods_nomenclature_item_id', | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
it { is_expected.to eq(expected) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters