-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add batch search endpoint #1299
Conversation
e632103
to
88d883c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good. I've a few comments about style/lint type things, just so we can keep the git history clean.
class BatchQuery < Query | ||
class TooManyQueries < Error; end | ||
def run(searches_params) | ||
raise(TooManyQueries, 'Maximum of 10 searches per batch') unless searches_params.count <= 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add something to the commit message to indicate that this is a fairly arbitrary number and it's small because we're cautious?
end | ||
|
||
def log_search_count(searches) | ||
GovukStatsd.increment "batch_search_#{searches.count}_searches" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
lib/search/query.rb
Outdated
@@ -61,39 +90,13 @@ def run_spell_checks(search_params) | |||
return unless suggestion_blocklist.should_correct?(search_params.query) | |||
|
|||
query = { | |||
size: 0, | |||
suggest: QueryComponents::Suggest.new(search_params).payload | |||
size: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the linter didn't pick up extra whitespace 🤔 It'd be good to remove this, as it will preserve the blame
trail better.
process_es_response(search_params, builder, payload, es_response) | ||
end | ||
|
||
private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think very much has changed here. I wonder if it's possible to split the method extraction into a separate commit. It might make it easier to reason about when we come back to it in future?
"format" => "local_transaction", | ||
"link" => "/URL", | ||
"_type" => "edition", | ||
"title" => "TITLE1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about ditching the whitespace as before - if nothing's changed we don't want to obscure the git history.
88d883c
to
053e717
Compare
053e717
to
945cc15
Compare
@oscarwyatt Would be good to get the linting errors fixed so we unblock merging of alphagov/gds-api-adapters#855 |
…uery Fixed linting issues
945cc15
to
8afd936
Compare
@vanitabarrett Apologies, fixed now |
Trello: https://trello.com/c/3KbtCe3D/123-add-batchsearch-endpoint-to-rummager
Adds a batch search endpoint so that multiple searches can be processed with a single Rummager query. Uses Elasticsearch multi query to process the searches efficiently as a single Elasticsearch call.
It can process multiple searches with an example url such as:
It allows a maximum of 10 searches per request at the moment. There is no technical reason for this it's completely arbitrary so this can be changed in the future if the need arises