Created
January 26, 2012 20:54
-
-
Save elight/1685054 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.2p290 :019 > ap Team.search("Manchester United").second | |
Team Load (3.5ms) SELECT "teams".*, ts_rank(to_tsvector('english', "teams"."name"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."description"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."icon"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."url"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."stadium"::text), to_tsquery('english', 'Manchester\ United'::text)) AS "rank0.14952106945761412" FROM "teams" WHERE (to_tsvector('english', "teams"."name"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."description"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."icon"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."url"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."stadium"::text) @@ to_tsquery('english', 'Manchester\ United'::text)) ORDER BY teams.name, "rank0.14952106945761412" DESC | |
#<Team:0x007fb7c3a652e8> { | |
:id => 48, | |
:name => "X-Man Utd", | |
:description => "Manchester United", | |
:icon => http://kyck-development.s3.amazonaws.com/uploads/teams/icon/48/images-24.jpeg, | |
:icon_ratio => 0.986725663716814, | |
:url => "null", | |
:league_id => nil, | |
:league_position => 0, | |
:opta_id => nil, | |
:stadium => nil, | |
:alias_id => nil, | |
:system => nil | |
} | |
=> #<Team id: 48, name: "X-Man Utd", description: "Manchester United", icon: "images-24.jpeg", icon_ratio: 0.986725663716814, url: "null", league_id: nil, league_position: 0, opta_id: nil, stadium: nil, alias_id: nil, system: nil> | |
1.9.2p290 :020 > ap Team.search("Manchester United").first | |
Team Load (3.4ms) SELECT "teams".*, ts_rank(to_tsvector('english', "teams"."name"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."description"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."icon"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."url"::text), to_tsquery('english', 'Manchester\ United'::text)) + ts_rank(to_tsvector('english', "teams"."stadium"::text), to_tsquery('english', 'Manchester\ United'::text)) AS "rank0.3352971143712422" FROM "teams" WHERE (to_tsvector('english', "teams"."name"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."description"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."icon"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."url"::text) @@ to_tsquery('english', 'Manchester\ United'::text) OR to_tsvector('english', "teams"."stadium"::text) @@ to_tsquery('english', 'Manchester\ United'::text)) ORDER BY teams.name, "rank0.3352971143712422" DESC LIMIT 1 | |
#<Team:0x007fb7c3a27678> { | |
:id => 142, | |
:name => "Manchester United", | |
:description => "null", | |
:icon => http://kyck-development.s3.amazonaws.com/uploads/teams/icon/142/images-24.jpeg, | |
:icon_ratio => 0.986725663716814, | |
:url => "null", | |
:league_id => 1, | |
:league_position => 0, | |
:opta_id => 1, | |
:stadium => "Old Trafford", | |
:alias_id => nil, | |
:system => nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment