Class: ThinkingSphinx::AttributeTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/attribute_types.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



4
5
6
# File 'lib/thinking_sphinx/attribute_types.rb', line 4

def self.call
  @call ||= new.call
end

.resetObject



8
9
10
# File 'lib/thinking_sphinx/attribute_types.rb', line 8

def self.reset
  @call = nil
end

Instance Method Details

#callObject



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
# File 'lib/thinking_sphinx/attribute_types.rb', line 12

def call
  return {} unless File.exist?(configuration_file)

  realtime_indices.each { |index|
    map_types_with_prefix index, :rt,
      [:uint, :bigint, :float, :timestamp, :string, :bool, :json]

    index.rt_attr_multi.each     { |name| attributes[name] << :uint }
    index.rt_attr_multi_64.each  { |name| attributes[name] << :bigint }
  }

  plain_sources.each { |source|
    map_types_with_prefix source, :sql,
      [:uint, :bigint, :float, :timestamp, :string, :bool, :json]

    source.sql_attr_str2ordinal    { |name| attributes[name] << :uint }
    source.sql_attr_str2wordcount  { |name| attributes[name] << :uint }
    source.sql_attr_multi.each { |setting|
      type, name, *ignored = setting.split(/\s+/)
      attributes[name] << type.to_sym
    }
  }

  attributes.values.each &:uniq!
  attributes
end