tsvector

Retrieving the most common keywords from a tsvector column

I'm considering adding a tsvector column to an existing table that will hold possible search terms for multiple columns in that same table (e.g. the tsvector column will equal to_tsvector(header || ' ' || body || ' ' || footer)). Before I decide to do so, one of my requirements is that I am able to find the most popular keywords amongst...

Disabling the PostgreSQL 8.4 tsvector parser's `file` token type

I have some documents that contain sequences such as radio/tested that I would like to return hits in queries like select * from doc where to_tsvector('english',body) @@ to_tsvector('english','radio') Unfortunately, the default parser takes radio/tested as a file token (despite being in a Windows environment), so it doesn't match the ...

Postgres full text search across multiple related tables

This may be a very simplistic question, so apologies in advance, but I am very new to database usage. I'd like to have Postgres run its full text search across multiple joined tables. Imagine something like a model User, with related models UserProfile and UserInfo. The search would only be for Users, but would include information fro...

Is there a simple method to remove the occurrence of lexeme in a tsvector?

I've got a tsvector column in a table and I would like to be able to remove a lexeme from the tsvector. I've started playing around with ts_stat to rebuild a new tsvector, but it seems quite complicated. Is there a simple way to do it? ...

Rails migrations with database-specific data types

I'm currently running a Rails migration where I am adding a datatype specific to Postgres, the tsvector. It holds search information in the form that Postgres expects for its built-in text searching capabilities. This is the line from my migration: t.column "search_vectors", :tsvector Everything seems to be working fine, and the sea...

Ruby on Rails: How to sanitize a string for SQL when not using find?

I'm trying to sanitize a string that involves user input without having to resort to manually crafting my own possibly buggy regex if possible, however, if that is the only way I would also appreciate if anyone can point me in the right direction to a regex that is unlikely to be missing anything. There are a number of methods in Rails t...