Thread

  1. Having a equal (=) operator on GIN-indexable columns

    Andreas Joseph Krogh <andreak@officenet.no> — 2011-06-13T19:34:27Z

    Hi!
    
    I'm not sure how to write a good $subject for this , but here it goes;
    I'd like to have a multi-column index on a varchar-field and a
    tsvector-field. GIN only likes tsvector-fields so I'm wondering if it's
    possible to create a tsvector from a text which doesn't breake the text
    up in vectors, but uses the whole string as the vector instead?
    
    Given the schema:
    
    CREATE TABLE mytable(
    id SERIAL PRIMAY KEY,
    field VARCHAR NOT NULL,
    tsvector_col tsvector NOT NULL
    );
    
    I'd like to form a query as follows:
    SELECT id FROM mytable WHERE tsvector_col @@ to_tsquery('simple',
    'andre:*') AND to_tsvector('simple', field) @@ to_tsquery('simple',
    'full_text_search');
    
    And I'd like it to be semantically equivalent of:
    SELECT id FROM mytable WHERE tsvector_col LIKE 'andrea%' AND field =
    'full_text_search';
    
    But I see that 'full_text_search' is broken up (of course):
    andreak=# select to_tsvector('simple', 'full_text_search');
             to_tsvector         
    ------------------------------
     'full':1 'search':3 'text':2
    
    Is it a way to achieve what I'm trying here?
    
    -- 
    Andreas Joseph Krogh <andreak@officenet.no>
    Senior Software Developer / CTO
    Public key: http://home.officenet.no/~andreak/public_key.asc
    ------------------------+---------------------------------------------+
    OfficeNet AS            | The most difficult thing in the world is to |
    Rosenholmveien 25       | know how to do a thing and to watch         |
    1414 Trollåsen          | somebody else doing it wrong, without       |
    NORWAY                  | comment.                                    |
    Org.nr: NO 981 479 076  |                                             |
                            |                                             |
    Tlf:    +47 24 15 38 90 |                                             |
    Fax:    +47 24 15 38 91 |                                             |
    Mobile: +47 909  56 963 |                                             |
    ------------------------+---------------------------------------------+