From 4bd16f053847f2efe347ebda9136ef2233ee0d2c Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 28 Apr 2009 00:15:53 +0200 Subject: added thinking_sphinx plugin for fulltext search on nodes and heads --- .../thinking-sphinx/spec/fixtures/models.rb | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 vendor/plugins/thinking-sphinx/spec/fixtures/models.rb (limited to 'vendor/plugins/thinking-sphinx/spec/fixtures/models.rb') diff --git a/vendor/plugins/thinking-sphinx/spec/fixtures/models.rb b/vendor/plugins/thinking-sphinx/spec/fixtures/models.rb new file mode 100644 index 0000000..0e62906 --- /dev/null +++ b/vendor/plugins/thinking-sphinx/spec/fixtures/models.rb @@ -0,0 +1,94 @@ +class Person < ActiveRecord::Base + belongs_to :team, :polymorphic => :true + has_many :contacts + + has_many :friendships + has_many :friends, :through => :friendships + + has_many :tags + + has_many :football_teams, :through => :tags + + define_index do + indexes [first_name, middle_initial, last_name], :as => :name + indexes team.name, :as => :team_name + indexes contacts.phone_number, :as => :phone_numbers + indexes city, :prefixes => true + indexes state, :infixes => true + + has [first_name, middle_initial, last_name], :as => :name_sort + has team.name, :as => :team_name_sort + + has [:id, :team_id], :as => :ids + has team(:id), :as => :team_id + + has contacts.phone_number, :as => :phone_number_sort + has contacts(:id), :as => :contact_ids + + has birthday + + has friendships.person_id, :as => :friendly_ids + + set_property :delta => true + end +end + +class Parent < Person +end + +class Child < Person + belongs_to :parent + define_index do + indexes [parent.first_name, parent.middle_initial, parent.last_name], :as => :parent_name + end +end + +class Contact < ActiveRecord::Base + belongs_to :person +end + +class Tag < ActiveRecord::Base + belongs_to :person + belongs_to :football_team + belongs_to :cricket_team +end + +class FootballTeam < ActiveRecord::Base + has_many :tags +end + +class CricketTeam < ActiveRecord::Base + define_index do + indexes :name + has "SELECT cricket_team_id, id FROM tags", :source => :query, :as => :tags + end +end + +class Friendship < ActiveRecord::Base + belongs_to :person + belongs_to :friend, :class_name => "Person", :foreign_key => :friend_id + + define_index do + has person_id, friend_id + end +end + +class Alpha < ActiveRecord::Base + define_index do + indexes :name, :sortable => true + + set_property :field_weights => {"name" => 10} + end +end + +class Beta < ActiveRecord::Base + define_index do + indexes :name, :sortable => true + + set_property :delta => true + end +end + +class Search < ActiveRecord::Base + # +end \ No newline at end of file -- cgit v1.3