Home > database >  How to create a full text index with PHP attributes and Symfony 6?
How to create a full text index with PHP attributes and Symfony 6?

Time:05-13

I need to create a search input inside my symfony 6.0 project. I'm using PHP 8.1.5

In the old days i used the following syntax with annotations :

/**
 * @ORM\Table(name="category", indexes={@ORM\Index(columns={"name", "description"}, flags={"fulltext"})})
 */
class Category
{

But right now i'm not able to find the good way to do it using attributes. I tried the following :

#[ORM\Index(name: 'category_idx', columns: ['name', 'description'])] 

but the migration didn't create a full text index.

Could you please tell me how you did it if you already had this situation ?

CodePudding user response:

For those who are looking for the same answer here it is.

#[ORM\Index(name: 'category_idx', columns: ['name', 'description'], flags: ['fulltext'])]

This will indeed create a TABLE with a fulltext index.

  • Related