Class: ThinkingSphinx::Index
- Inherits:
-
Object
- Object
- ThinkingSphinx::Index
show all
- Defined in:
- lib/thinking_sphinx/index.rb,
lib/thinking_sphinx/index/builder.rb,
lib/thinking_sphinx/index/faux_column.rb
Defined Under Namespace
Classes: Builder, FauxColumn
Instance Attribute Summary (collapse)
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Constructor Details
- (Index) initialize(model, &block)
Create a new index instance by passing in the model it is tied to, and a
block to build it with (optional but recommended). For documentation on the
syntax for inside the block, the Builder class is what you want.
Quick Example:
Index.new(User) do
indexes login, email
has created_at
set_property :delta => true
end
22
23
24
25
26
27
28
29
|
# File 'lib/thinking_sphinx/index.rb', line 22
def initialize(model, &block)
@name = self.class.name_for model
@model = model
@sources = []
@options = {}
@delta_object = nil
@additional_indices = []
end
|
Instance Attribute Details
- (Object) additional_indices
Returns the value of attribute additional_indices
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def additional_indices
@additional_indices
end
|
- (Object) delta_object
Returns the value of attribute delta_object
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def delta_object
@delta_object
end
|
- (Object) model
Returns the value of attribute model
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def model
@model
end
|
- (Object) name
Returns the value of attribute name
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def name
@name
end
|
- (Object) sources
Returns the value of attribute sources
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def sources
@sources
end
|
Class Method Details
+ (Object) name_for(model)
54
55
56
|
# File 'lib/thinking_sphinx/index.rb', line 54
def self.name_for(model)
model.name.underscore.tr(':/\\', '_')
end
|
Instance Method Details
- (Object) all_names
47
48
49
50
51
52
|
# File 'lib/thinking_sphinx/index.rb', line 47
def all_names
names = [core_name]
names << delta_name if delta?
names
end
|
- (Object) attributes
35
36
37
|
# File 'lib/thinking_sphinx/index.rb', line 35
def attributes
@sources.collect { |source| source.attributes }.flatten
end
|
- (Object) core_name
39
40
41
|
# File 'lib/thinking_sphinx/index.rb', line 39
def core_name
"#{name}_core"
end
|
- (Boolean) delta?
79
80
81
|
# File 'lib/thinking_sphinx/index.rb', line 79
def delta?
!@delta_object.nil?
end
|
- (Object) delta_name
43
44
45
|
# File 'lib/thinking_sphinx/index.rb', line 43
def delta_name
"#{name}_delta"
end
|
- (Object) fields
31
32
33
|
# File 'lib/thinking_sphinx/index.rb', line 31
def fields
@sources.collect { |source| source.fields }.flatten
end
|
- (Object) infix_fields
62
63
64
|
# File 'lib/thinking_sphinx/index.rb', line 62
def infix_fields
fields.select { |field| field.infixes }
end
|
- (Object) local_options
66
67
68
|
# File 'lib/thinking_sphinx/index.rb', line 66
def local_options
@options
end
|
- (Object) options
70
71
72
73
74
75
76
77
|
# File 'lib/thinking_sphinx/index.rb', line 70
def options
all_index_options = config.index_options.clone
@options.keys.select { |key|
ThinkingSphinx::Configuration::IndexOptions.include?(key.to_s) ||
ThinkingSphinx::Configuration::CustomOptions.include?(key.to_s)
}.each { |key| all_index_options[key.to_sym] = @options[key] }
all_index_options
end
|
- (Object) prefix_fields
58
59
60
|
# File 'lib/thinking_sphinx/index.rb', line 58
def prefix_fields
fields.select { |field| field.prefixes }
end
|
- (Object) to_riddle(offset)
83
84
85
86
87
|
# File 'lib/thinking_sphinx/index.rb', line 83
def to_riddle(offset)
indexes = [to_riddle_for_core(offset)]
indexes << to_riddle_for_delta(offset) if delta?
indexes << to_riddle_for_distributed
end
|