Skip to content

Commit

Permalink
Merge pull request #403 from trln/bugfix-query-truncation-fallback
Browse files Browse the repository at this point in the history
Bugfix: provide a fallback term cap (20) for basic searches within f…
  • Loading branch information
kazymovae authored Jun 27, 2023
2 parents e74478d + 2d8890e commit 8830155
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.10
2.2.11
5 changes: 5 additions & 0 deletions lib/trln_argon/argon_search_builder/clause_count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def clause_count(solr_parameters)
when 'isbn_issn'
# 117 + "edismax", "qf", "isbn_issn_qf", "pf", "pf3", "pf2"
length = 123
else
# 20 fallback for any other search field, e.g., call_number
# Note that call_number may have its own search builder, see:
# https://github.com/trln/argon_call_number_search
length = 19
end

truncate_query(solr_parameters, length)
Expand Down
16 changes: 16 additions & 0 deletions spec/lib/trln_argon/argon_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,22 @@
'One two three four five six seven eight')
end
end

context 'Any other field search: query contains more than 20 terms' do
let(:builder_with_params) do
search_builder.with(
q: '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 '\
'21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40',
'search_field' => 'call_number'
)
end

it 'truncates query at 20 terms' do
expect(solr_parameters[:q]).to eq(\
'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20'
)
end
end
end
end
# rubocop:enable RSpec/NestedGroups
Expand Down

0 comments on commit 8830155

Please sign in to comment.