Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres fulltext index

Tags:

CREATE INDEX message_fulltext_idx ON feedback USING gin(to_tsvector(message));
ERROR:  functions in index predicate must be marked IMMUTABLE 

How to avoid this?

like image 792
m621 Avatar asked Apr 05 '12 11:04

m621


People also ask

What is full text search Postgres?

Full Text Search is used by search engines, shops, and many other websites all around the world. By default, searches on PostgreSQL database are exact.

What is a gin index?

GIN stands for Generalized Inverted Index. GIN is designed for handling cases where the items to be indexed are composite values, and the queries to be handled by the index need to search for element values that appear within the composite items.

What is the use of fulltext index?

Full-text indexes are created on text-based columns ( CHAR , VARCHAR , or TEXT columns) to speed up queries and DML operations on data contained within those columns. A full-text index is defined as part of a CREATE TABLE statement or added to an existing table using ALTER TABLE or CREATE INDEX .

Is PostgreSQL good for full text search?

Yes, You Can Keep Full-Text Search in Postgres You can get even deeper and make your Postgres full-text search even more robust, by implementing features such as highlighting results, or writing your own custom dictionaries or functions.


1 Answers

You need to include the optional config parameter. Without it, the function is not immutable. For example, if you want the standard English text parsing:

CREATE INDEX message_fulltext_idx ON feedback
  USING gin(to_tsvector('english', message));
like image 56
kgrittn Avatar answered Sep 23 '22 15:09

kgrittn