DoctrineFullTextPostrgres icon indicating copy to clipboard operation
DoctrineFullTextPostrgres copied to clipboard

Useless when there are multiple tsvector fields for the same text field

Open teohhanhui opened this issue 9 years ago • 3 comments

The first tsvector field that contains the field is used: https://github.com/jaimz22/DoctrineFullTextPostrgres/blob/86bca023c972d0f08988c3c912bb6d4c77c400bf/src/ORM/Query/AST/Functions/TSFunction.php#L59-L62

To fix this, we have to allow the user to directly specify the tsvector field to use, instead of using the underlying field in the query.

Example:

tsquery(a.titleAndBodyFts, :searchQuery)

teohhanhui avatar Sep 08 '16 17:09 teohhanhui

sorry, can you elaborate?

jaimz22 avatar Sep 08 '16 17:09 jaimz22

Using the example in the README:

class Article
{
    /**
     * @var string
     * @Column(name="title", type="string", nullable=false)
     */
    private $title;

    /**
     * @TsVector(name="title_fts", fields={"title"})
     */
    private $titleFTS;

    /**
     * @var string
     * @Column(name="body", type="text", nullable=true)
     */
    private $body;

    /**
     * @TsVector(name="body_fts", fields={"body"})
     */
    private $bodyFTS;

    /**
     * @TsVector(name="title_and_body_fts", fields={"title", "body"})
     */
    private $titleAndBodyFTS;
}

We can never do the query against title_and_body_fts with the current design.

tsquery(a.title, :searchQuery) would use title_fts, and tsquery(a.body, :searchQuery) would use body_fts.

teohhanhui avatar Sep 08 '16 18:09 teohhanhui

I propose removing the text field -> tsvector field rewriting magic in the query.

teohhanhui avatar Sep 08 '16 18:09 teohhanhui