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 --- .../plugins/thinking-sphinx/spec/fixtures/data.sql | 32 ++++++++ .../spec/fixtures/database.yml.default | 3 + .../thinking-sphinx/spec/fixtures/models.rb | 94 +++++++++++++++++++++ .../thinking-sphinx/spec/fixtures/structure.sql | 95 ++++++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 vendor/plugins/thinking-sphinx/spec/fixtures/data.sql create mode 100644 vendor/plugins/thinking-sphinx/spec/fixtures/database.yml.default create mode 100644 vendor/plugins/thinking-sphinx/spec/fixtures/models.rb create mode 100644 vendor/plugins/thinking-sphinx/spec/fixtures/structure.sql (limited to 'vendor/plugins/thinking-sphinx/spec/fixtures') diff --git a/vendor/plugins/thinking-sphinx/spec/fixtures/data.sql b/vendor/plugins/thinking-sphinx/spec/fixtures/data.sql new file mode 100644 index 0000000..d5ec579 --- /dev/null +++ b/vendor/plugins/thinking-sphinx/spec/fixtures/data.sql @@ -0,0 +1,32 @@ +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Ellie','K','Ford','38 Mills Street','Eagle Farm Bc','QLD','4009','Ellie.K.Ford@mailinator.com','1970/1/23 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Aaliyah','E','Allen','71 Murphy Street','Wyola West','WA','6407','Aaliyah.E.Allen@dodgit.com','1980/3/23 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Callum','C','Miah','89 Dalgarno Street','Bullawa Creek','NSW','2390','Callum.C.Miah@trashymail.com','1973/3/25 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Finley','L','Buckley','18 Queen Street','Manly Vale','NSW','2093','Finley.L.Buckley@spambob.com','1962/11/20 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Poppy','A','Hilton','36 Nerrigundah Drive','Nyora','VIC','3987','Poppy.A.Hilton@dodgit.com','1972/10/30 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Eloise','Z','Kennedy','18 Mt Berryman Road','Lilydale','QLD','4344','Eloise.Z.Kennedy@spambob.com','1973/9/28 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Shannon','L','Manning','60 Ocean Pde','Greenvale','QLD','4816','Shannon.L.Manning@dodgit.com','1956/6/13 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Oscar','C','Lawson','43 Feather Street','Battery Hill','QLD','4551','Oscar.C.Lawson@spambob.com','1979/10/17 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('female','Sofia','K','Bray','26 Clifton Street','Pental Island','VIC','3586','Sofia.K.Bray@mailinator.com','1970/5/10 00:00:00', 3, 'CricketTeam'); +insert into `people` (gender, first_name, middle_initial, last_name, street_address, city, state, postcode, email, birthday, team_id, team_type) values('male','Andrew','N','Byrne','35 Cecil Street','Monash Park','NSW','2111','Andrew.N.Byrne@spambob.com','1983/2/16 00:00:00', 3, 'CricketTeam'); + +insert into `alphas` (name) values ('one'); +insert into `alphas` (name) values ('two'); +insert into `alphas` (name) values ('three'); +insert into `alphas` (name) values ('four'); +insert into `alphas` (name) values ('five'); +insert into `alphas` (name) values ('six'); +insert into `alphas` (name) values ('seven'); +insert into `alphas` (name) values ('eight'); +insert into `alphas` (name) values ('nine'); +insert into `alphas` (name) values ('ten'); + +insert into `betas` (name) values ('one'); +insert into `betas` (name) values ('two'); +insert into `betas` (name) values ('three'); +insert into `betas` (name) values ('four'); +insert into `betas` (name) values ('five'); +insert into `betas` (name) values ('six'); +insert into `betas` (name) values ('seven'); +insert into `betas` (name) values ('eight'); +insert into `betas` (name) values ('nine'); +insert into `betas` (name) values ('ten'); diff --git a/vendor/plugins/thinking-sphinx/spec/fixtures/database.yml.default b/vendor/plugins/thinking-sphinx/spec/fixtures/database.yml.default new file mode 100644 index 0000000..dfad2a6 --- /dev/null +++ b/vendor/plugins/thinking-sphinx/spec/fixtures/database.yml.default @@ -0,0 +1,3 @@ +username: root +password: +host: localhost \ No newline at end of file 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 diff --git a/vendor/plugins/thinking-sphinx/spec/fixtures/structure.sql b/vendor/plugins/thinking-sphinx/spec/fixtures/structure.sql new file mode 100644 index 0000000..4ab390d --- /dev/null +++ b/vendor/plugins/thinking-sphinx/spec/fixtures/structure.sql @@ -0,0 +1,95 @@ +DROP TABLE IF EXISTS `people`; + +CREATE TABLE `people` ( + `id` int(11) NOT NULL auto_increment, + `first_name` varchar(50) NULL, + `middle_initial` varchar(10) NULL, + `last_name` varchar(50) NULL, + `gender` varchar(10) NULL, + `street_address` varchar(200) NULL, + `city` varchar(100) NULL, + `state` varchar(100) NULL, + `postcode` varchar(10) NULL, + `email` varchar(100) NULL, + `birthday` datetime NULL, + `team_id` int(11) NULL, + `team_type` varchar(50) NULL, + `type` varchar(50) NULL, + `parent_id` varchar(50) NULL, + `delta` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `friendships`; + +CREATE TABLE `friendships` ( + `id` int(11) NOT NULL auto_increment, + `person_id` int(11) NOT NULL, + `friend_id` int(11) NOT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `football_teams`; + +CREATE TABLE `football_teams` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `state` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `cricket_teams`; + +CREATE TABLE `cricket_teams` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `state` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `contacts`; + +CREATE TABLE `contacts` ( + `id` int(11) NOT NULL auto_increment, + `phone_number` varchar(50) NOT NULL, + `person_id` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `alphas`; + +CREATE TABLE `alphas` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `betas`; + +CREATE TABLE `betas` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + `delta` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `searches`; + +CREATE TABLE `searches` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `tags`; + +CREATE TABLE `tags` ( + `id` int(11) NOT NULL auto_increment, + `person_id` int(11) NOT NULL, + `football_team_id` int(11) NOT NULL, + `cricket_team_id` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- cgit v1.3