background preloader

PostgreSQL Full Text Search

Facebook Twitter

Full Text Indexing with PostgreSQL - PostgreSQL Wiki. This article discusses full text indexing with the contrib/fulltextindex module only. More advanced indexing is available via the contrib/tsearch module, which is not covered here. The contrib/fulltextindex module is a quick and easy way of achieving basic text indexing under PostgreSQL. The module is available in 7.1 and below with the ability to index one column per table, and in 7.2 is able to index an arbitrary number of columns per table. This form of full text indexing works by recording all possible suffixes of the words it indexes. For instance, the word 'sydney' would have strings of Sydney, 'ydney', 'dney', 'ney' and 'ey' stored.

Anyway - that's technical stuff! Installation Once you have configured and installed PostgreSQL, you need to change to the contrib/fulltextindex directory in the source tarball. To enable full text indexing in one of your databases, issue the following SQL: CREATE FUNCTION fti() RETURNS opaque AS '/path/to/fti.so' LANGUAGE 'C'; 1. Eg. 2. 3. 4. 1. 2. 3. 4.

Full Text Search In PostgreSQL. PostgreSQL 8.4 doc : Recherche plein texte. La recherche plein texte (ou plus simplement la recherche de texte) permet de sélectionner des documents en langage naturel qui satisfont une requête et, en option, de les trier par intérêt suivant cette requête. Le type le plus fréquent de recherche concerne la récupération de tous les documents contenant les termes de recherche indiqués et de les renvoyer dans un ordre dépendant de leur similarité par rapport à la requête.

Les notions de requête et de similarité peuvent beaucoup varier et dépendent de l'application réelle. La recherche la plus simple considère une requête comme un ensemble de mots et la similarité comme la fréquence des mots de la requête dans le document. Les opérateurs de recherche plein texte existent depuis longtemps dans les bases de données. Aucun support linguistique, même pour l'anglais. L'indexage pour la recherche plein texte permet au document d'être pré-traité et qu'un index de ce pré-traitement soit sauvegardé pour une recherche ultérieure plus rapide.

Postgresql Full Text Search - Planquez ces chiffres! Admettons que l'on veuille sauver des textes cryptés dans la colonne d'une table Postgresql. Rien de plus facile en utilisant les fonctions pgp_sym_encrypt et pgp_sym_decrypt. Jusque là, tout va bien. Mais admettons maintenant que l'on veuille également pouvoir faire des recherches rapides sur ces textes en utilisant le Full Text Search. L'on rajoute une colonne de type tsvector, et l'on parse le texte là dedans.

Patatras, votre vilain espion peut maintenant recréer le document en regardant ce champ, qui, lui, ne peut pas être crypté! L'on peut bien sûr monter ses données sur une partition cryptée. Cependant, admettons encore (ça fait beaucoup, je sais!) Ça tombe bien, il est possible de créer une nouvelle configuration qui escamotera ce genre de données. Ajoutons donc la configuration french_safe: Alors que de la configuration de base, tout un tas de données sensibles auraient pu être extraites: la nouvelle configuration, elle, garde nos petits secrets bien au chaud!

PostgreSQL: A full text search engine - Part 2 | shisaa.jp. Welcome to the second installment of our look into full text search within PostgreSQL. If this is the first time you heard about full text search I highly encourage you to go and read the first chapter in this series before continuing. This chapter builds on what we have seen previously. A look back In short, the previous chapter introduced the general concept of full text search, regardless of the software being used. Next we delved into PostgreSQL's implementation and introduced the tsvector and the tsquery as two new data types together with a handful of new functions such as to_tsvector(), to_tsquery() and plainto_tsquery(), which all extend PostgreSQL to support full text search. We saw how we could feed PostgreSQL a string of text which would then get parsed into tokens and processed even further into lexemes which in turn got stored into a tsvector. In this chapter, I want to flesh out an important topic we touched on in previously: PostgreSQL's full text search configurations.

Aha!