in opensearch-dsl/lib/opensearch/dsl/search.rb [269:284]
def to_hash
hash = {}
hash.update(query: @query.to_hash) if @query
hash.update(filter: @filter.to_hash) if @filter
hash.update(post_filter: @post_filter.to_hash) if @post_filter
hash.update(aggregations: @aggregations.reduce({}) { |sum,item| sum.update item.first => item.last.to_hash }) if @aggregations
hash.update(sort: @sort.to_hash) if @sort
hash.update(size: @size) if @size
hash.update(stored_fields: @stored_fields) if @stored_fields
hash.update(from: @from) if @from
hash.update(suggest: @suggest.reduce({}) { |sum,item| sum.update item.last.to_hash }) if @suggest
hash.update(highlight: @highlight.to_hash) if @highlight
hash.update(@options) unless @options.empty?
hash
end