Class: ODBA::FulltextIndex

Inherits:
IndexCommon show all
Defined in:
lib/odba/index.rb

Overview

:nodoc: all

Constant Summary

Constants inherited from IndexCommon

IndexCommon::ODBA_EXCLUDE_VARS

Constants included from Persistable

Persistable::Exact, Persistable::Find, Persistable::ODBA_EXCLUDE_VARS, Persistable::ODBA_INDEXABLE, Persistable::ODBA_PREDEFINE_EXCLUDE_VARS, Persistable::ODBA_PREDEFINE_SERIALIZABLE, Persistable::ODBA_PREFETCH, Persistable::ODBA_SERIALIZABLE

Instance Attribute Summary

Attributes inherited from IndexCommon

#class_filter, #index_name, #origin_klass, #resolve_origin, #resolve_search_term, #resolve_target, #target_klass

Attributes included from Persistable

#odba_id, #odba_name, #odba_persistent, #odba_prefetch

Instance Method Summary collapse

Methods inherited from IndexCommon

#delete, #delete_target, #fill, #keys, #matches, #origin_class?, #proc_instance_origin, #proc_instance_target, #proc_resolve_search_term, #search_term, #search_terms, #set_relevance, #update, #update_origin, #update_target

Methods included from Persistable

#==, append_features, #dup, #eql?, #odba_add_observer, #odba_collection, #odba_cut_connection, #odba_delete, #odba_delete_observer, #odba_delete_observers, #odba_dup, #odba_exclude_vars, #odba_indexable?, #odba_isolated_dump, #odba_isolated_store, #odba_isolated_stub, #odba_isolated_twin, #odba_notify_observers, #odba_observers, #odba_potentials, #odba_prefetch?, #odba_replace!, #odba_replace_persistables, #odba_replace_stubs, #odba_restore, #odba_serializables, #odba_snapshot, #odba_store, #odba_store_unsaved, #odba_stubize, #odba_take_snapshot, #odba_target_ids, #odba_unsaved?, #odba_unsaved_neighbors, sanitize

Constructor Details

#initialize(index_definition, origin_module) ⇒ FulltextIndex

:nodoc:



365
366
367
368
# File 'lib/odba/index.rb', line 365

def initialize(index_definition, origin_module)  # :nodoc:
	super(index_definition, origin_module)
	ODBA.storage.create_fulltext_index(@index_name)
end

Instance Method Details

#current_origin_ids(target_id) ⇒ Object



369
370
371
372
373
# File 'lib/odba/index.rb', line 369

def current_origin_ids(target_id)
  ODBA.storage.fulltext_index_delete(@index_name, target_id,
                                     'target_id')
  []
end

#current_target_ids(origin_id) ⇒ Object



374
375
376
# File 'lib/odba/index.rb', line 374

def current_target_ids(origin_id)
  ODBA.storage.fulltext_index_target_ids(@index_name, origin_id)
end

#delete_origin(origin_id, term) ⇒ Object



377
378
379
380
# File 'lib/odba/index.rb', line 377

def delete_origin(origin_id, term)
  ODBA.storage.fulltext_index_delete(@index_name, origin_id, 
                                     'origin_id')
end

#do_update_index(origin_id, search_text, target_id = nil) ⇒ Object

:nodoc:



387
388
389
# File 'lib/odba/index.rb', line 387

def do_update_index(origin_id, search_text, target_id=nil) # :nodoc:
  ODBA.storage.update_fulltext_index(@index_name, origin_id, search_text, target_id)
end

#fetch_ids(search_term, meta = nil) ⇒ Object

:nodoc:



381
382
383
384
385
386
# File 'lib/odba/index.rb', line 381

def fetch_ids(search_term, meta=nil)  # :nodoc:
    limit = meta.respond_to?(:limit) && meta.limit
	rows = ODBA.storage.retrieve_from_fulltext_index(@index_name, search_term, limit)
	set_relevance(meta, rows)
	rows.collect { |row| row.at(0) }
end