jaimz22 / DoctrineFullTextPostrgres

A simple to use set of database types, and annotations to use postgresql's full text search engine with doctrine
17 stars 21 forks source link

Symfont 3.1.2 error #11

Closed freezlite closed 7 years ago

freezlite commented 7 years ago

The class "VertigoLabs\DoctrineFullTextPostgres\DBAL\Types\TsVector" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to a
dd @Annotation to the class doc comment of "VertigoLabs\DoctrineFullTextPostgres\DBAL\Types\TsVector". If it is indeed no annotation, then you need to add @IgnoreAnnotation("TsVector") to the clas
s
doc comment of property AppBundle\Entity\User::$aboutFTS.

jaimz22 commented 7 years ago

what does your config look like?

\VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVectorType is the annotation class

freezlite commented 7 years ago

There is no \VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVectorType class at README.md

freezlite commented 7 years ago

my config.yml

doctrine:
    dbal:
        driver:   pdo_pgsql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #     path:     "%database_path%"
        types:
            tsvector: VertigoLabs\DoctrineFullTextPostgres\DBAL\Types\TsVector

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                auto_mapping: true
                naming_strategy: doctrine.orm.naming_strategy.underscore
                dql:    
                    string_functions:
                        tsquery: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsQueryFunction
                        tsrank: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankFunction
                        tsrankcd: VertigoLabs\DoctrineFullTextPostgres\ORM\Query\AST\Functions\TsRankCDFunction

My User Entity

<?php

namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping as TsVectorType;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser {

    //...

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    protected $about;

    /**
     * @TsVectorType\TsVector(fields={"about"})
     */
    protected $aboutFTS;
}

php bin/console doctrine:schema:update --force Nothing to update - your database is already in sync with the current entity metadata.

Now no errors but no aboutFTS field at database

jaimz22 commented 7 years ago

There is no \VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVectorType class at README.md

Sorry I meant VertigoLabs\DoctrineFullTextPostgres\ORM\Mapping\TsVector

So you've got an existing entity that you're trying to add the TsVector too? I'm just trying to replicate the issue so I can fix it

jaimz22 commented 7 years ago

@freezlite Also, could you take a look at this https://github.com/jaimz22/DoctrineFullTextPostrgresBundle and give it a shot, I'm curious if it gives you the same issue.

freezlite commented 7 years ago

@freezlite Also, could you take a look at this https://github.com/jaimz22/DoctrineFullTextPostrgresBundle and give it a shot, I'm curious if it gives you the same issue.

Problem 1

So you've got an existing entity that you're trying to add the TsVector too? I'm just trying to replicate the issue so I can fix it

I'm trying to add full text search for single column in exists Entity. But seems it not creates any new tsvector fields at database.

freezlite commented 7 years ago

Ok, I understood. You should add to section for Symfony users lines about services.yml

vertigolabs.doctrinefulltextpostgres.listener:
        class: VertigoLabs\DoctrineFullTextPostgres\Common\TsVectorSubscriber
        tags:
            - { name: doctrine.event_subscriber, connection: default }

and/or

mapping_types:
            tsvector: tsvector

After this working fine. Problem that I'm not advanced user of symfony or doctrine and I need exact how to.

jaimz22 commented 7 years ago

yes, the readme.md got updated in a pull request and it's incorrect. I'll update it. Or if you'd like you can make a new PR and I'll merge it.

freezlite commented 7 years ago

Sorry, with my English I can make more mistakes.

jaimz22 commented 7 years ago

I got it all updated, thanks.