Kliver Max
Kliver Max

Reputation: 5299

How to make fulltext search in PostgreSQL useful?

I have a russian dictionary in postgresql 8.4.

I try to use full search but have some troubles.

  1. I dont get any results becouse try to find words by 4-5symbols. For example:

    select * from parcels_temp where name_dispatcher @@ to_tsquery('Нику');
    

    Get result: 0 rows.

    select * from parcels_temp where name_dispatcher @@ to_tsquery('Никуд');
    

    Get result: 2 rows. its correct.

  2. I try to do search by words not contained in dictionary. What i gonna do in this case? How can i update dictionary in PostgreSQL?

  3. Its must create column to tsvector or i can use to_tsvector function i queries? Or its more slowly?

Upvotes: 0

Views: 181

Answers (2)

Innerpeacer
Innerpeacer

Reputation: 1321

1: By default, postgreSQL only matches the whole word. You can opt in to do a prefix matching:

select * from parcels_temp where name_dispatcher @@ to_tsquery('Нику:*');

See: https://www.postgresql.org/docs/9.5/static/textsearch-controls.html

3: You can create a column and GIN index on it, or you can just create the index without creating a column. I think they are the same in terms of performance. For details, see: https://www.postgresql.org/docs/9.5/static/textsearch-tables.html

Upvotes: 0

Nikita Dubrovin
Nikita Dubrovin

Reputation: 41

  1. Postgresql indexer does not process strings shorter than 3 characters. It is done to reduce index size and generation time.

  2. Obviously, you get nothing. There is way to update dictionary, refer to documentation.

  3. Use GIN index on tsvector field.

Upvotes: 1

Related Questions