Nope, it's empty. When I run to_tsvector function I get:

p1_development=> SELECT to_tsvector(CAST('simple' AS regconfig), 
(COALESCE(title, ''))) FROM videos;

        to_tsvector         

----------------------------

 'new':2 'test':1 'video':3

 'testing':1

 'testtest':1

 'name':2 'new':1 'video':3

 'videos':1

(5 rows)


and when I run plainto_tsquery function I get:


p1_development=> SELECT plainto_tsquery(CAST('simple' AS regconfig), 'vid');

 plainto_tsquery 

-----------------

 'vid'

(1 row)

If I change AND to OR, it works properly:

p1_development=> SELECT * FROM videos WHERE ((to_tsvector(CAST('simple' AS 
regconfig), (COALESCE(title, ''))) @@ plainto_tsquery(CAST('simple' AS 
regconfig), 'vid')) OR (((COALESCE(title, '')) ILIKE '%vid%' ESCAPE '\')));

 id |     title      |   url_m3u8   |   url_mp4    |         created_at     
    |         updated_at         | external_id | vidible_id 

----+----------------+--------------+--------------+----------------------------+----------------------------+-------------+------------

  1 | Test new video | 123123       | 123123       | 2016-05-12 
12:56:57.087443 | 2016-05-12 12:56:57.087443 |             | 

  4 | New name video | vtslvntsr.   | ;vtnrskvtrsj | 2016-05-12 
12:58:04.112812 | 2016-05-12 12:58:04.112812 |             | 

  5 | Videos         | egtsgtrsgtrb | yrdbydb      | 2016-05-12 
12:58:17.049731 | 2016-05-12 12:58:17.049731 |             | 

(3 rows)


четверг, 12 мая 2016 г., 19:38:35 UTC+3 пользователь Jeremy Evans написал:
>
> On Thursday, May 12, 2016 at 9:26:26 AM UTC-7, Aleksey Dashkevich wrote:
>>
>> In local DB I have 5 videos with titles: Test new video, Testing*, *
>> testiest, New name video, Videos
>> When I make request  
>> *Video*.dataset.full_text_search(:title, *'*vid*'*, {phrase: *true*
>> }).all 
>> I get empty array. 
>> I get raw SQL of this request  
>> #<Sequel::Postgres::Dataset: "SELECT * FROM \"videos\" WHERE 
>> ((to_tsvector(CAST('simple' AS regconfig), (COALESCE(\"title\", ''))) @@ 
>> plainto_tsquery(CAST('simple' AS regconfig), 'vid')) AND 
>> (((COALESCE(\"title\", '')) ILIKE '%vid%' ESCAPE '\\')))">
>> and run last part  
>> *DB*.fetch(*"*SELECT * FROM videos WHERE ((COALESCE(title, '')) ILIKE 
>> '%vid%' ESCAPE '*\\*')*"*).all 
>> and get expected 3 videos
>> Then I run 
>> *DB*.fetch(*"*SELECT * FROM videos WHERE ((to_tsvector(CAST('simple' AS 
>> regconfig), (COALESCE(title, ''))) @@ plainto_tsquery(CAST('simple' AS 
>> regconfig), 'vid')))*"*).all 
>> and get empty array.
>> Then I check dictionaries and simple dictionary:
>>
>> *DB*.fetch(*"*SELECT dictname FROM pg_catalog.pg_ts_dict;*"*).all
>>
>> => [{:dictname=>*"*simple*"*}, ... ]
>>
>>
>> *DB*.fetch(*"*SELECT * FROM ts_debug('vid');*"*).all
>>
>> => [{:alias=>*"*asciiword*"*, :description=>*"*Word, all ASCII*"*, :token
>> =>*"*vid*"*, :dictionaries=>*"*{simple}*"*, :dictionary=>*"*simple*"*, 
>> :lexemes=>[*"*vid*"*]}]
>>
>>
>> Of course, I can use 
>>
>> *Video*.where(*Sequel*.ilike(:title, *'*%vid%*'*)).all
>>
>> but maybe I do something wrong with full_text_search ??
>>
>> Thank you =)
>>
>
> Does running the full text search SQL on PostgreSQL return any rows?  If 
> so, and Sequel is not returning rows even though PostgreSQL is returning 
> rows, then it may be a Sequel bug, in which case you should post a self 
> contained example showing the problem.  If PostgreSQL doesn't return any 
> rows either, you should probably as the PostgreSQL developers.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to