Module: ModelGen
Instance Method Summary collapse
-
#addToMapping(f, field_name, map) ⇒ Object
Add non-facet field to mapping (name, data type, mapping).
-
#duplicateUnanalyzedFacet(f) ⇒ Object
Make a duplicate that isn't analyzed for facets.
-
#fieldMapping(f) ⇒ Object
Generate mapping for particular field.
-
#genMapping(settings, dataspec) ⇒ Object
Generate mapping based on dataspec/settings.
Instance Method Details
#addToMapping(f, field_name, map) ⇒ Object
Add non-facet field to mapping (name, data type, mapping)
21 22 23 |
# File 'app/models/model_gen.rb', line 21 def addToMapping(f, field_name, map) return attribute field_name.to_sym, f["Type"], mapping: map end |
#duplicateUnanalyzedFacet(f) ⇒ Object
Make a duplicate that isn't analyzed for facets
26 27 28 |
# File 'app/models/model_gen.rb', line 26 def duplicateUnanalyzedFacet(f) return attribute (f["Field Name"]+"_facet").to_sym, f["Type"], mapping: {index: "not_analyzed", fielddata: {format: "doc_values"}} end |
#fieldMapping(f) ⇒ Object
Generate mapping for particular field
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/model_gen.rb', line 31 def fieldMapping(f) map = Hash.new # Set to correct analyzer if f["Mapping"] == "not_analyzed" map[:index] = f["Mapping"] elsif f["Mapping"] == "english" map[:analyzer] = "custom_en_analyzer" end return map end |
#genMapping(settings, dataspec) ⇒ Object
Generate mapping based on dataspec/settings
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/model_gen.rb', line 3 def genMapping(settings, dataspec) fieldhash = Hash.new dataspec.field_info.each do |f| # Set mapping map = fieldMapping(f) # If facet, make separate analyzed version. if dataspec.facet_fields.include?(f["Field Name"]) addToMapping(f, f["Field Name"], map) duplicateUnanalyzedFacet(f) else # For non-facets addToMapping(f, f["Field Name"], map) end end end |