Module: SearchFlip::Sourceable

Included in:
Aggregation, Criteria
Defined in:
lib/search_flip/sourceable.rb

Overview

The SearchFlip::Sortable mixin provides the chainable #source method to use elasticsearch source filtering

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
# File 'lib/search_flip/sourceable.rb', line 6

def self.included(base)
  base.class_eval do
    attr_accessor :source_value
  end
end

Instance Method Details

#source(value) ⇒ SearchFlip::Criteria

Use to specify which fields of the source document you want Elasticsearch to return for each matching result.

Examples:

CommentIndex.source([:id, :message]).search("hello world")
CommentIndex.source(exclude: "description")
CommentIndex.source(false)

Parameters:

  • value

    Pass any allowed value to restrict the returned source

Returns:



24
25
26
27
28
# File 'lib/search_flip/sourceable.rb', line 24

def source(value)
  fresh.tap do |criteria|
    criteria.source_value = value
  end
end