Class: Chewy::Search::Request
- Defined in:
- lib/chewy/search/request.rb
Overview
The class tries to be as immutable as possible, so most of the methods return a new instance of the class.
The main requset DSL class. Supports multiple index requests. Supports ES2 and ES5 search API and query DSL.
Constant Summary collapse
- UNDEFINED =
Class.new.freeze
- EVERFIELDS =
%w[_index _type _id _parent].freeze
- DELEGATED_METHODS =
i[ query filter post_filter order reorder docvalue_fields track_scores request_cache explain version profile search_type preference limit offset terminate_after timeout min_score source stored_fields search_after load script_fields suggest aggs aggregations none indices_boost rescore highlight total total_count total_entries types delete_all count exists? exist? find pluck scroll_batches scroll_hits scroll_results scroll_wrappers ].to_set.freeze
- DEFAULT_BATCH_SIZE =
1000- DEFAULT_PLUCK_BATCH_SIZE =
10_000- DEFAULT_SCROLL =
'1m'.freeze
- FIELD_STORAGES =
An array of storage names that are modifying returned fields in hits
i[ source docvalue_fields script_fields stored_fields ].freeze
- EXTRA_STORAGES =
An array of storage names that are not related to hits at all.
i[aggs suggest].freeze
- WHERE_STORAGES =
An array of storage names that are changing the returned hist collection in any way.
i[ query filter post_filter none types min_score rescore indices_boost ].freeze
Instance Attribute Summary collapse
-
#_indexes ⇒ Object
readonly
Returns the value of attribute _indexes.
-
#_types ⇒ Object
readonly
Returns the value of attribute _types.
Chainable request modificators collapse
-
#aggs(value = UNDEFINED) ⇒ Object
(also: #aggregations)
A dual-purpose method.
-
#docvalue_fields(*values) ⇒ Chewy::Search::Request
Modifies
docvalue_fieldsrequest parameter. -
#explain(value = true) ⇒ Chewy::Search::Request
Replaces the value of the
explainparameter with the provided value. -
#filter(query_hash = nil, &block) ⇒ Chewy::Search::Request, Chewy::Search::QueryProxy
Adds
filtecontext of thequerparameter at the search request body. -
#highlight(value) ⇒ Chewy::Search::Request
Add a
highlightconfiguration to the request. -
#indices_boost(value) ⇒ Chewy::Search::Request
Add an
indices_boostpart to the request. -
#limit(value) ⇒ Chewy::Search::Request
Replaces the value of the
sizerequest part. -
#load(options = nil) ⇒ Object
Stores ORM/ODM objects loading options.
-
#min_score(value) ⇒ Chewy::Search::Request
Replaces the value of the
min_scorerequest part. -
#none(value = true) ⇒ Chewy::Search::Request
Enables
NullObjectpattern for the request, doesn't perform the request,#hitsare empty,#totalis 0, etc. -
#offset(value) ⇒ Chewy::Search::Request
Replaces the value of the
fromrequest part. -
#order(*values) ⇒ Chewy::Search::Request
Modifies
sortrequest parameter. -
#post_filter(query_hash = nil, &block) ⇒ Chewy::Search::Request, Chewy::Search::QueryProxy
Adds
post_filterparameter to the search request body. -
#preference(value) ⇒ Chewy::Search::Request
Replaces the value of the
preferencerequest part. -
#profile(value = true) ⇒ Chewy::Search::Request
Replaces the value of the
profileparameter with the provided value. -
#query(query_hash = nil, &block) ⇒ Chewy::Search::Request, Chewy::Search::QueryProxy
Adds
querparameter to the search request body. -
#reorder(*values) ⇒ Chewy::Search::Request
Replaces the value of the
sortparameter with the provided value. -
#request_cache(value) ⇒ Chewy::Search::Request
Replaces the value of the
request_cacheparameter with the provided value. -
#rescore(value) ⇒ Chewy::Search::Request
Add a
rescorepart to the request. -
#script_fields(value) ⇒ Chewy::Search::Request
Add a
script_fieldspart to the request. -
#search_after(*values) ⇒ Chewy::Search::Request
Replaces the storage value for
search_afterrequest part. -
#search_type(value) ⇒ Chewy::Search::Request
Replaces the value of the
search_typerequest part. -
#source(*values) ⇒ Chewy::Search::Request
Updates
_sourcerequest part. -
#stored_fields(*values) ⇒ Chewy::Search::Request
Updates
stored_fieldsrequest part. -
#suggest(value = UNDEFINED) ⇒ Object
A dual-purpose method.
-
#terminate_after(value) ⇒ Chewy::Search::Request
Replaces the value of the
terminate_afterrequest part. -
#timeout(value) ⇒ Chewy::Search::Request
Replaces the value of the
timeoutrequest part. -
#track_scores(value = true) ⇒ Chewy::Search::Request
Replaces the value of the
track_scoresparameter with the provided value. -
#types(*values) ⇒ Chewy::Search::Request
Modifies
typesrequest parameter. -
#version(value = true) ⇒ Chewy::Search::Request
Replaces the value of the
versionparameter with the provided value.
Scopes manipulation collapse
-
#and(other) ⇒ Chewy::Search::Request
Takes
query,filter,post_filterfrom the passed scope and performs QueryProxy#and operation for each of them. -
#except(*values) ⇒ Chewy::Search::Request
Returns a new scope containing all the storages except specified.
-
#merge(other) ⇒ Chewy::Search::Request
Merges 2 scopes by merging their parameters.
-
#not(other) ⇒ Chewy::Search::Request
Takes
query,filter,post_filterfrom the passed scope and performs QueryProxy#not operation for each of them. -
#only(*values) ⇒ Chewy::Search::Request
Returns a new scope containing only specified storages.
-
#or(other) ⇒ Chewy::Search::Request
Takes
query,filter,post_filterfrom the passed scope and performs QueryProxy#or operation for each of them.
Additional actions collapse
-
#count ⇒ Integer
Returns total count of hits for the request.
-
#delete_all(refresh: true) ⇒ Hash
Deletes all the documents from the specified scope it uses
delete_by_queryAPI. -
#exists? ⇒ true, false
(also: #exist?)
Checks if any of the document exist for this request.
-
#find(*ids) ⇒ Object
Finds documents with specified ids for the current request scope.
-
#first(limit = UNDEFINED) ⇒ Object
Return first wrapper object or a collection of first N wrapper objects if the argument is provided.
-
#pluck(*fields) ⇒ Object
Returns and array of values for specified fields.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Compare two scopes or scope with a collection of wrappers.
-
#initialize(*indexes_or_types) ⇒ Request
constructor
The class is initialized with the list of chewy indexes and/or types, which are later used to compose requests.
-
#inspect ⇒ String
Includes the class name and the result of rendering.
-
#parameters ⇒ Chewy::Search::Parameters
Underlying parameter storage collection.
-
#render ⇒ Hash
ES request body.
-
#response ⇒ Chewy::Search::Response
Access to ES response wrappers providing useful methods such as Chewy::Search::Response#total or Chewy::Search::Response#max_score.
Methods included from Scrolling
#scroll_batches, #scroll_hits, #scroll_objects, #scroll_wrappers
Methods included from Scoping
Constructor Details
#initialize(*indexes_or_types) ⇒ Request
The class is initialized with the list of chewy indexes and/or types, which are later used to compose requests.
67 68 69 70 71 72 |
# File 'lib/chewy/search/request.rb', line 67 def initialize(*indexes_or_types) @_types = indexes_or_types.select { |klass| klass < Chewy::Type } @_indexes = indexes_or_types.select { |klass| klass < Chewy::Index } @_types |= @_indexes.flat_map(&:types) @_indexes |= @_types.map(&:index) end |
Instance Attribute Details
#_indexes ⇒ Object (readonly)
Returns the value of attribute _indexes.
54 55 56 |
# File 'lib/chewy/search/request.rb', line 54 def _indexes @_indexes end |
#_types ⇒ Object (readonly)
Returns the value of attribute _types.
54 55 56 |
# File 'lib/chewy/search/request.rb', line 54 def _types @_types end |
Instance Method Details
#==(other) ⇒ true, false
Compare two scopes or scope with a collection of wrappers. If other is a collection it performs the request to fetch data from ES.
96 97 98 |
# File 'lib/chewy/search/request.rb', line 96 def ==(other) super || other.is_a?(Chewy::Search::Request) ? compare_internals(other) : to_a == other end |
#aggs(value) ⇒ Chewy::Search::Request #aggs ⇒ Hash Also known as: aggregations
A dual-purpose method.
669 670 671 672 673 674 675 |
# File 'lib/chewy/search/request.rb', line 669 def aggs(value = UNDEFINED) if value == UNDEFINED response.aggs else modify(:aggs) { update!(value) } end end |
#and(other) ⇒ Chewy::Search::Request
Takes query, filter, post_filter from the passed scope
and performs QueryProxy#and operation for each
of them. Unlike merge, every other parameter is kept unmerged
(values from the first scope are used in the result scope).
746 747 748 749 750 751 752 |
# File 'lib/chewy/search/request.rb', line 746 i[and or not].each do |name| define_method name do |other| i[query filter post_filter].inject(self) do |scope, parameter_name| scope.send(parameter_name).send(name, other.parameters[parameter_name].value) end end end |
#count ⇒ Integer
Returns total count of hits for the request. If the request
was already performed - it uses the total value, otherwise
it executes a fast count request.
783 784 785 786 787 788 789 790 791 |
# File 'lib/chewy/search/request.rb', line 783 def count if performed? total else Chewy.client.count(only(WHERE_STORAGES).render)['count'] end rescue Elasticsearch::Transport::Transport::Errors::NotFound 0 end |
#delete_all(refresh: true) ⇒ Hash
The result hash is different for different API used.
Deletes all the documents from the specified scope it uses
delete_by_query API. For ES < 5.0 it uses delete_by_query
plugin, which requires additional installation effort.
912 913 914 915 916 917 918 919 920 921 922 923 924 |
# File 'lib/chewy/search/request.rb', line 912 def delete_all(refresh: true) request_body = only(WHERE_STORAGES).render.merge(refresh: refresh) ActiveSupport::Notifications.instrument 'delete_query.chewy', request: request_body, indexes: _indexes, types: _types, index: _indexes.one? ? _indexes.first : _indexes, type: _types.one? ? _types.first : _types do if Runtime.version < '5.0' delete_by_query_plugin(request_body) else Chewy.client.delete_by_query(request_body) end end end |
#docvalue_fields(*values) ⇒ Chewy::Search::Request
Modifies docvalue_fields request parameter. Updates the storage on every call.
296 297 298 299 300 |
# File 'lib/chewy/search/request.rb', line 296 i[order docvalue_fields types].each do |name| define_method name do |value, *values| modify(name) { update!([value, *values]) } end end |
#except(*values) ⇒ Chewy::Search::Request
Returns a new scope containing all the storages except specified.
772 773 774 |
# File 'lib/chewy/search/request.rb', line 772 def except(*values) chain { parameters.except!(values.flatten(1)) } end |
#exists? ⇒ true, false Also known as: exist?
Checks if any of the document exist for this request. If
the request was already performed - it uses the total,
otherwise it executes a fast request to check existence.
798 799 800 801 802 803 804 |
# File 'lib/chewy/search/request.rb', line 798 def exists? if performed? total != 0 else limit(0).terminate_after(1).total != 0 end end |
#explain(value = true) ⇒ Chewy::Search::Request
Replaces the value of the explain parameter with the provided value.
381 382 383 384 385 |
# File 'lib/chewy/search/request.rb', line 381 i[track_scores explain version profile none].each do |name| define_method name do |value = true| modify(name) { replace!(value) } end end |
#filter(query_hash) ⇒ Chewy::Search::Request #filter { ... } ⇒ Chewy::Search::Request #filter ⇒ Chewy::Search::QueryProxy
Adds filte context of the quer parameter at the
search request body.
253 254 255 256 257 258 259 260 261 |
# File 'lib/chewy/search/request.rb', line 253 i[query filter post_filter].each do |name| define_method name do |query_hash = UNDEFINED, &block| if block || query_hash != UNDEFINED modify(name) { must(block || query_hash) } else Chewy::Search::QueryProxy.new(name, self) end end end |
#find(id) ⇒ Chewy::Type #find(*ids) ⇒ Array<Chewy::Type>
Finds documents with specified ids for the current request scope.
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 |
# File 'lib/chewy/search/request.rb', line 850 def find(*ids) return super if block_given? ids = ids.flatten(1).map(&:to_s) scope = except(EXTRA_STORAGES).filter(ids: {values: ids}) results = if ids.size > DEFAULT_BATCH_SIZE scope.scroll_wrappers else scope.limit(ids.size) end.to_a if ids.size != results.size missing_ids = ids - results.map(&:id).map(&:to_s) raise Chewy::DocumentNotFound, "Could not find documents for ids: #{missing_ids.to_sentence}" end results.one? ? results.first : results end |
#first ⇒ Chewy::Type #first(limit) ⇒ Array<Chewy::Type>
Return first wrapper object or a collection of first N wrapper objects if the argument is provided. Tries to use cached results of possible. If the amount of cached results is insufficient - performs a new request.
823 824 825 826 827 828 829 830 831 832 |
# File 'lib/chewy/search/request.rb', line 823 def first(limit = UNDEFINED) request_limit = limit == UNDEFINED ? 1 : limit if performed? && (request_limit <= size || size == total) limit == UNDEFINED ? wrappers.first : wrappers.first(limit) else result = except(EXTRA_STORAGES).limit(request_limit).to_a limit == UNDEFINED ? result.first : result end end |
#highlight(value) ⇒ Chewy::Search::Request
Add a highlight configuration to the request. Further
call values are merged to the storage hash.
603 604 605 606 607 |
# File 'lib/chewy/search/request.rb', line 603 i[script_fields indices_boost rescore highlight].each do |name| define_method name do |value| modify(name) { update!(value) } end end |
#indices_boost(value) ⇒ Chewy::Search::Request
Add an indices_boost part to the request. Further
call values are merged to the storage hash.
603 604 605 606 607 |
# File 'lib/chewy/search/request.rb', line 603 i[script_fields indices_boost rescore highlight].each do |name| define_method name do |value| modify(name) { update!(value) } end end |
#inspect ⇒ String
Includes the class name and the result of rendering.
119 120 121 |
# File 'lib/chewy/search/request.rb', line 119 def inspect "<#{self.class} #{render}>" end |
#limit(value) ⇒ Chewy::Search::Request
Replaces the value of the size request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#load(options = nil) ⇒ Object
Stores ORM/ODM objects loading options. Options
might be define per-type or be global, depends on the adapter
loading implementation. Also, there are 2 loading options to select
or exclude types from loading: only and except respectively.
Options are updated on further method calls.
544 545 546 |
# File 'lib/chewy/search/request.rb', line 544 def load( = nil) modify(:load) { update!() } end |
#merge(other) ⇒ Chewy::Search::Request
Merges 2 scopes by merging their parameters.
692 693 694 |
# File 'lib/chewy/search/request.rb', line 692 def merge(other) chain { parameters.merge!(other.parameters) } end |
#min_score(value) ⇒ Chewy::Search::Request
Replaces the value of the min_score request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#none(value = true) ⇒ Chewy::Search::Request
Enables NullObject pattern for the request, doesn't perform the
request, #hits are empty, #total is 0, etc.
381 382 383 384 385 |
# File 'lib/chewy/search/request.rb', line 381 i[track_scores explain version profile none].each do |name| define_method name do |value = true| modify(name) { replace!(value) } end end |
#not(other) ⇒ Chewy::Search::Request
Takes query, filter, post_filter from the passed scope
and performs QueryProxy#not operation for each
of them. Unlike merge, every other parameter is kept unmerged
(values from the first scope are used in the result scope).
746 747 748 749 750 751 752 |
# File 'lib/chewy/search/request.rb', line 746 i[and or not].each do |name| define_method name do |other| i[query filter post_filter].inject(self) do |scope, parameter_name| scope.send(parameter_name).send(name, other.parameters[parameter_name].value) end end end |
#offset(value) ⇒ Chewy::Search::Request
Replaces the value of the from request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#only(*values) ⇒ Chewy::Search::Request
Returns a new scope containing only specified storages.
761 762 763 |
# File 'lib/chewy/search/request.rb', line 761 def only(*values) chain { parameters.only!(values.flatten(1)) } end |
#or(other) ⇒ Chewy::Search::Request
Takes query, filter, post_filter from the passed scope
and performs QueryProxy#or operation for each
of them. Unlike merge, every other parameter is kept unmerged
(values from the first scope are used in the result scope).
746 747 748 749 750 751 752 |
# File 'lib/chewy/search/request.rb', line 746 i[and or not].each do |name| define_method name do |other| i[query filter post_filter].inject(self) do |scope, parameter_name| scope.send(parameter_name).send(name, other.parameters[parameter_name].value) end end end |
#order(*values) ⇒ Chewy::Search::Request
Modifies sort request parameter. Updates the storage on every call.
296 297 298 299 300 |
# File 'lib/chewy/search/request.rb', line 296 i[order docvalue_fields types].each do |name| define_method name do |value, *values| modify(name) { update!([value, *values]) } end end |
#parameters ⇒ Chewy::Search::Parameters
Underlying parameter storage collection.
77 78 79 |
# File 'lib/chewy/search/request.rb', line 77 def parameters @parameters ||= Parameters.new end |
#pluck(field) ⇒ Array<Object> #pluck(*fields) ⇒ Array<Array<Object>>
Returns and array of values for specified fields.
Uses source to restrict the list of returned fields.
Fields _id, _type and _index are also supported.
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'lib/chewy/search/request.rb', line 884 def pluck(*fields) fields = fields.flatten(1).reject(&:blank?).map(&:to_s) source_fields = fields - EVERFIELDS scope = except(FIELD_STORAGES, EXTRA_STORAGES) .source(source_fields.presence || false) hits = raw_limit_value ? scope.hits : scope.scroll_hits(batch_size: DEFAULT_PLUCK_BATCH_SIZE) hits.map do |hit| if fields.one? fetch_field(hit, fields.first) else fields.map do |field| fetch_field(hit, field) end end end end |
#post_filter(query_hash) ⇒ Chewy::Search::Request #post_filter { ... } ⇒ Chewy::Search::Request #post_filter ⇒ Chewy::Search::QueryProxy
Adds post_filter parameter to the search request body.
253 254 255 256 257 258 259 260 261 |
# File 'lib/chewy/search/request.rb', line 253 i[query filter post_filter].each do |name| define_method name do |query_hash = UNDEFINED, &block| if block || query_hash != UNDEFINED modify(name) { must(block || query_hash) } else Chewy::Search::QueryProxy.new(name, self) end end end |
#preference(value) ⇒ Chewy::Search::Request
Replaces the value of the preference request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#profile(value = true) ⇒ Chewy::Search::Request
Replaces the value of the profile parameter with the provided value.
381 382 383 384 385 |
# File 'lib/chewy/search/request.rb', line 381 i[track_scores explain version profile none].each do |name| define_method name do |value = true| modify(name) { replace!(value) } end end |
#query(query_hash) ⇒ Chewy::Search::Request #query { ... } ⇒ Chewy::Search::Request #query ⇒ Chewy::Search::QueryProxy
Adds quer parameter to the search request body.
253 254 255 256 257 258 259 260 261 |
# File 'lib/chewy/search/request.rb', line 253 i[query filter post_filter].each do |name| define_method name do |query_hash = UNDEFINED, &block| if block || query_hash != UNDEFINED modify(name) { must(block || query_hash) } else Chewy::Search::QueryProxy.new(name, self) end end end |
#render ⇒ Hash
ES request body
112 113 114 |
# File 'lib/chewy/search/request.rb', line 112 def render @render ||= render_base.merge(parameters.render) end |
#reorder(*values) ⇒ Chewy::Search::Request
312 313 314 |
# File 'lib/chewy/search/request.rb', line 312 def reorder(value, *values) modify(:order) { replace!([value, *values]) } end |
#request_cache(value) ⇒ Chewy::Search::Request
Replaces the value of the request_cache parameter with the provided value.
Unlike other boolean fields, the value have to be specified explicitly
since it overrides the index-level setting.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#rescore(value) ⇒ Chewy::Search::Request
Add a rescore part to the request. Further
call values are added to the storage array.
603 604 605 606 607 |
# File 'lib/chewy/search/request.rb', line 603 i[script_fields indices_boost rescore highlight].each do |name| define_method name do |value| modify(name) { update!(value) } end end |
#response ⇒ Chewy::Search::Response
Access to ES response wrappers providing useful methods such as Chewy::Search::Response#total or Chewy::Search::Response#max_score.
105 106 107 |
# File 'lib/chewy/search/request.rb', line 105 def response @response ||= Response.new(perform, loader, collection_paginator) end |
#script_fields(value) ⇒ Chewy::Search::Request
Add a script_fields part to the request. Further
call values are merged to the storage hash.
603 604 605 606 607 |
# File 'lib/chewy/search/request.rb', line 603 i[script_fields indices_boost rescore highlight].each do |name| define_method name do |value| modify(name) { update!(value) } end end |
#search_after(*values) ⇒ Chewy::Search::Request
Replaces the storage value for search_after request part.
528 529 530 |
# File 'lib/chewy/search/request.rb', line 528 def search_after(value, *values) modify(:search_after) { replace!(values.empty? ? value : [value, *values]) } end |
#search_type(value) ⇒ Chewy::Search::Request
Replaces the value of the search_type request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#source(*values) ⇒ Chewy::Search::Request
Updates _source request part. Accepts either an array
of field names/templates or a hash with includes and excludes
keys. Source also can be disabled entierly or enabled again.
512 513 514 515 516 |
# File 'lib/chewy/search/request.rb', line 512 i[source stored_fields].each do |name| define_method name do |value, *values| modify(name) { update!(values.empty? ? value : [value, *values]) } end end |
#stored_fields(*values) ⇒ Chewy::Search::Request
Updates stored_fields request part. Accepts an array of field
names. Can be entierly disabled and enabled back.
512 513 514 515 516 |
# File 'lib/chewy/search/request.rb', line 512 i[source stored_fields].each do |name| define_method name do |value, *values| modify(name) { update!(values.empty? ? value : [value, *values]) } end end |
#suggest(value) ⇒ Chewy::Search::Request #suggest ⇒ Hash
A dual-purpose method.
635 636 637 638 639 640 641 |
# File 'lib/chewy/search/request.rb', line 635 def suggest(value = UNDEFINED) if value == UNDEFINED response.suggest else modify(:suggest) { update!(value) } end end |
#terminate_after(value) ⇒ Chewy::Search::Request
Replaces the value of the terminate_after request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#timeout(value) ⇒ Chewy::Search::Request
Replaces the value of the timeout request part.
478 479 480 481 482 |
# File 'lib/chewy/search/request.rb', line 478 i[request_cache search_type preference timeout limit offset terminate_after min_score].each do |name| define_method name do |value| modify(name) { replace!(value) } end end |
#track_scores(value = true) ⇒ Chewy::Search::Request
Replaces the value of the track_scores parameter with the provided value.
381 382 383 384 385 |
# File 'lib/chewy/search/request.rb', line 381 i[track_scores explain version profile none].each do |name| define_method name do |value = true| modify(name) { replace!(value) } end end |
#types(*values) ⇒ Chewy::Search::Request
Modifies types request parameter. Updates the storage on every call.
Constrains types passed on the request initialization.
296 297 298 299 300 |
# File 'lib/chewy/search/request.rb', line 296 i[order docvalue_fields types].each do |name| define_method name do |value, *values| modify(name) { update!([value, *values]) } end end |
#version(value = true) ⇒ Chewy::Search::Request
Replaces the value of the version parameter with the provided value.
381 382 383 384 385 |
# File 'lib/chewy/search/request.rb', line 381 i[track_scores explain version profile none].each do |name| define_method name do |value = true| modify(name) { replace!(value) } end end |