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
#initialize(model, &block) ⇒ Index
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
|
# 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
end
|
Instance Attribute Details
#delta_object ⇒ 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
|
#model ⇒ Object
Returns the value of attribute model.
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def model
@model
end
|
#name ⇒ Object
Returns the value of attribute name.
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def name
@name
end
|
#sources ⇒ Object
Returns the value of attribute sources.
6
7
8
|
# File 'lib/thinking_sphinx/index.rb', line 6
def sources
@sources
end
|
Class Method Details
.name_for(model) ⇒ Object
53
54
55
|
# File 'lib/thinking_sphinx/index.rb', line 53
def self.name_for(model)
model.name.underscore.tr(':/\\', '_')
end
|
Instance Method Details
#all_names ⇒ Object
46
47
48
49
50
51
|
# File 'lib/thinking_sphinx/index.rb', line 46
def all_names
names = [core_name]
names << delta_name if delta?
names
end
|
#attributes ⇒ Object
34
35
36
|
# File 'lib/thinking_sphinx/index.rb', line 34
def attributes
@sources.collect { |source| source.attributes }.flatten
end
|
#core_name ⇒ Object
38
39
40
|
# File 'lib/thinking_sphinx/index.rb', line 38
def core_name
"#{name}_core"
end
|
#delta? ⇒ Boolean
78
79
80
|
# File 'lib/thinking_sphinx/index.rb', line 78
def delta?
!@delta_object.nil?
end
|
#delta_name ⇒ Object
42
43
44
|
# File 'lib/thinking_sphinx/index.rb', line 42
def delta_name
"#{name}_delta"
end
|
#fields ⇒ Object
30
31
32
|
# File 'lib/thinking_sphinx/index.rb', line 30
def fields
@sources.collect { |source| source.fields }.flatten
end
|
#infix_fields ⇒ Object
61
62
63
|
# File 'lib/thinking_sphinx/index.rb', line 61
def infix_fields
fields.select { |field| field.infixes }
end
|
#local_options ⇒ Object
65
66
67
|
# File 'lib/thinking_sphinx/index.rb', line 65
def local_options
@options
end
|
#prefix_fields ⇒ Object
57
58
59
|
# File 'lib/thinking_sphinx/index.rb', line 57
def prefix_fields
fields.select { |field| field.prefixes }
end
|
#to_riddle(offset) ⇒ Object
82
83
84
85
86
|
# File 'lib/thinking_sphinx/index.rb', line 82
def to_riddle(offset)
indexes = [to_riddle_for_core(offset)]
indexes << to_riddle_for_delta(offset) if delta?
indexes << to_riddle_for_distributed
end
|