-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding AllowPartialSearchResults parameter
Just adding this for completeness. I didn't really test using this so you can definitely remove this if it's not wanted. This support was added in ES 6.3. https://www.elastic.co/blog/this-week-in-elasticsearch-and-apache-lucene-2018-02-05
- Loading branch information
1 parent
63515c9
commit af46a81
Showing
3 changed files
with
33 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
lib/chewy/search/parameters/allow_partial_search_results.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,27 @@ | ||
require 'chewy/search/parameters/storage' | ||
|
||
module Chewy | ||
module Search | ||
class Parameters | ||
# Stores boolean value, but has 3 states: `true`, `false` and `nil`. | ||
# | ||
# @see Chewy::Search::Request#allow_partial_search_results | ||
# @see https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-request-body.html#_parameters_4 | ||
class AllowPartialSearchResults < Storage | ||
# We don't want to render `nil`, but render `true` and `false` values. | ||
# | ||
# @see Chewy::Search::Parameters::Storage#render | ||
# @return [{Symbol => Object}, nil] | ||
def render | ||
{self.class.param_name => value} unless value.nil? | ||
end | ||
|
||
private | ||
|
||
def normalize(value) | ||
!!value unless value.nil? | ||
end | ||
end | ||
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