Class: EagleSearch::Field
- Inherits:
-
Object
- Object
- EagleSearch::Field
- Defined in:
- lib/eagle_search/field.rb
Instance Method Summary collapse
-
#initialize(index, column) ⇒ Field
constructor
A new instance of Field.
- #mapping ⇒ Object
Constructor Details
#initialize(index, column) ⇒ Field
Returns a new instance of Field.
3 4 5 6 |
# File 'lib/eagle_search/field.rb', line 3 def initialize(index, column) @index = index @column = column end |
Instance Method Details
#mapping ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/eagle_search/field.rb', line 8 def mapping mapping = { type: type } index_settings = @index.settings if index_settings[:unsearchable_fields] && (index_settings[:unsearchable_fields].include?(@column.name) || index_settings[:unsearchable_fields].include?(@column.name.to_sym)) mapping[:index] = "no" else if type == "string" if index_settings[:exact_match_fields] && (index_settings[:exact_match_fields].include?(@column.name) || index_settings[:exact_match_fields].include?(@column.name.to_sym)) mapping[:index] = "not_analyzed" else mapping[:index] = "analyzed" mapping[:analyzer] = index_settings[:language] || "english" mapping[:fields] = { shingle: { type: "string", analyzer: "eagle_search_shingle_analyzer" }, autocomplete: { type: "string", index_analyzer: "eagle_search_autocomplete_analyzer", search_analyzer: index_settings[:language] || "english" } } mapping[:fields].merge!( { synonym: { type: "string", analyzer: "eagle_search_synonym_analyzer" } } ) if @index.has_synonyms? end end end mapping end |