2014-09-04 16 views
0

這是我的SQL我希望ts_query考慮文章,就像一個,如何做到這一點?

select * 
    from 
    my_table 
    where to_tsvector('english', description || keywords) @@ to_tsquery('a|an|the|it'); 

記錄

------------------------------- 
| id | Description   | 
------------------------------- 
| 1 | this is a first record | 
------------------------------- 
| 2 | its an second record | 
------------------------------- 
| 3 | a an the    | 
------------------------------- 
| 4 | he she it they   | 
------------------------------- 
+0

您可以創建不使用停用詞的自定義全文搜索詞典。 http://stackoverflow.com/questions/23991695/postgresql-full-text-search-characters-problème/23994141#23994141 – pozs 2014-09-04 11:34:48

回答

0

不要使用english作爲文本搜索配置,使用simple代替。

這一個工程

select to_tsvector('simple', 'a car') @@ to_tsquery('simple', 'a|an'); 

結果:

 
?column? 
---------- 
t 
(1 row) 

這一個不工作

select to_tsvector('english', 'a car') @@ to_tsquery('english', 'a|an'); 

結果:

 
NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored 
?column? 
---------- 
f 
(1 row) 
相關問題