簡體   English   中英

PostgreSQL中帶有tsquery的奇怪行為,前綴為lexemes

[英]Strange behavior with tsquery in PostgreSQL with prefix-lexemes

當我使用'a:*'(也是'i:*','s:*','t:*')

SELECT id FROM mv_fulltextsearch1 WHERE to_tsvector(text) @@ to_tsquery('a:*') LIMIT 50;

永遠占用並打印以下PostgreSQL輸出很多

NOTICE:  text-search query contains only stop words or doesn't contain lexemes, ignored

但是當我使用'b:*'時(與':*'前面的任何其他單個字母相同)

SELECT id FROM mv_fulltextsearch1 WHERE to_tsvector(text) @@ to_tsquery('b:*') LIMIT 50;

一切都好

a,i,s和t是某種特殊字符嗎? 我怎樣才能逃脫它們/修復這種奇怪的行為?

使用to_tsvector('simple', text)to_tsquery('simple', 'a:*')

原因是“英語”regconfig刪除了停用詞 ,“a”被認為是停用詞

但是,'simple'regconfig不會刪除停用詞

https://www.postgresql.org/docs/current/static/textsearch-controls.html#textsearch-parsing-queries

此外,*可以附加到詞位以指定前綴匹配:

https://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES

當基本tsquery輸入以面值取得標記時,to_tsquery使用指定或默認配置將每個標記規范化為一個lexeme,並根據配置丟棄任何停用單詞的標記。

這讓我得出一個結論,你的to_tsquery拋出一個作為停止的單詞,保持NO TEXT來查詢...(參見上面文檔中the rat and cat的例子)

(((請不要問什么停用詞為t)))

例如,如果你(沒有to_tsquery ,因此停止不被丟棄的話)

with c(t) as (values('a an also at bond'),('but by illegal'),('I in it aligator'))
select t,to_tsvector(t) @@ ('a:*')::tsquery from c;

         t         | ?column?
-------------------+----------
 a an also at bond | t
 but by illegal    | f
 I in it aligator  | t
(3 rows)

它會工作......

關於停用詞的參考:

-bash-4.2$ grep "^t$" /usr/share/pgsql93/tsearch_data/english.stop
t

t是一個...但我的英語知識溫和缺乏理解為什么

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM