I am investigating how the http://code.google.com/p/django-fts/ application works. I am trying to setup psql FTS to work with the application, but can't understand how to create index correctly.
Don't understand how to create the GIN index as it was 开发者_如何学Pythonspecified in doc.
My model is following:
class Product(fts.SearchableModel):
name = models.CharField(max_length = 1000)
description = models.TextField(blank = True)
in the database I have a table store_product
But when I am running the following in my psql, I have an error:
base=# CREATE INDEX "store_product_index" ON "store_product" USING gin("name");
ERROR: data type character varying has no default operator class for access method "gin"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
Can you help me to understand what is wrong here?
You need:
CREATE INDEX "store_product_index" ON "store_product" USING gin(to_tsvector('english', "name"));
(assuming you want the index on english). See section 12.2.2 in the documentation at http://www.postgresql.org/docs/9.0/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX
精彩评论