Add a FULLTEXT index in Doctrine 2 using annotations?

Solution 1:

According to DDC-3014 in the issue tracker of Doctrine, the possibility to specify full-text indices using annotations was implemented on April 14 and will be available in release 2.5. If you don't like to wait, you could try to use the unstable, development version or to backport the commit implementing the feature.

Here is a usage example:

/**
* @Entity
* @Table(indexes={@Index(columns={"content"}, flags={"fulltext"})})
*/
class Comment
{
    /**
    * @Column(type="text")
    */
    private $content;

    ...
}

Solution 2:

Here is an example how to make a fulltext index with the yaml mapping driver.

Doctrine\Tests\ORM\Mapping\Comment:
    type: entity
    fields:
        content:
            type: text
    indexes:
        xy_fulltext:
            columns: ["name", "content", "keywords"]
            flags: fulltext