1. Cannot create unique index on large text fields 2. Documentation regarding PostGresQL full-text search is unclear
What are you asking? The title of the issue says one thing, but the question within your post seems to be about adding a `unique` constraint to a `TextField`? In the example, "query" is a text search query. I'll rename to make it more clear. aa12e607e1b8d073875afbc761c55a2b572271aa > In the example, "query" is a text search query. I'll rename to make it more clear.

'cat & rat' as in `to_tsquery('cat & rat')`? https://www.postgresql.org/docs/9.1/static/functions-textsearch.html

> What are you asking?

Sorry. I did ask two questions. The first question is well answered, but for the second question, I suppose the answer is 

    content = TextField(unique=False)

Then,

    db.execute_sql('''
    CREATE UNIQUE INDEX unique_content_index ON cell (md5(content));
    ''')

But, how do I do it in pure peewee? You don't need to specify `unique=False` - this is the default behavior.

To create an index on an expression like that you have a couple options:

```python

# Method one.
Cell.add_index(fn.MD5(Cell.content), name='cell_content_hash', unique=True)

# Method two.
idx = Cell.index(fn.MD5(Cell.content), name='cell_content_hash', unique=True)
Cell.add_index(idx)

# Method three.
class Cell(Model):
    ...
    class Meta:
        indexes = [
            SQL('create unique index cell_content_hash on cell (md5(content))'),
        ]
``` Thanks for the answer. I would choose Method three.

Although, it would be simpler if I can do something directly in `content = TextField(index=...)` like

    content = TextField(index=fn.MD5, unique=True)

As a matter of fact, my problem was originally the content is so large the PostGres cannot unique-ify it.
What is `query` in `blog_search(query)` in http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#full-text-search ?

As a matter of fact, I am trying to do:

    class Cell(BaseModel):
        content = pv.TextField(unique=True)
    
    db_cell = Cell.get_or_none(Cell.content.contains(new_data))
    if db_cell is None:
        db_cell = Cell.create(
            content=new_data
        )

My current solution:

    class Cell(BaseModel):
        content = pv.TextField()
        search_content = TSVectorField()
        
        @classmethod
        def add_content(cls, content):
            return cls.create(
                content=content,
                search_content=fn.to_tsvector(content)
            )
        
    db_cell = Cell.get_or_none(Cell.search_content == fn.to_tsvector(new_data))

    if db_cell is None:
        db_cell = Cell.add_content(
            content=new_data
        )

I can't seem to add `unique=True` to content.