Class: ODBA::FulltextIndex

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

Overview

:nodoc: all

Constant Summary

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:



394
395
396
397
# File 'lib/odba/index.rb', line 394

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

Instance Method Details

#current_origin_ids(target_id) ⇒ Object



399
400
401
402
403
# File 'lib/odba/index.rb', line 399

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

#current_target_ids(origin_id) ⇒ Object



405
406
407
# File 'lib/odba/index.rb', line 405

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

#delete_origin(origin_id, term) ⇒ Object



409
410
411
412
# File 'lib/odba/index.rb', line 409

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:



421
422
423
# File 'lib/odba/index.rb', line 421

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:



414
415
416
417
418
419
# File 'lib/odba/index.rb', line 414

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