0
我需要在機器語言上進行文本搜索。如果我使用任何可用的文本搜索字典,ts_vectors都搞亂了。我可以在postgres ts_vector/ts_query全文搜索中禁用字典嗎?
ex。移動 - >變成mov,我的搜索失敗了。
任何想法如何索引非語言詞彙?
謝謝!
我需要在機器語言上進行文本搜索。如果我使用任何可用的文本搜索字典,ts_vectors都搞亂了。我可以在postgres ts_vector/ts_query全文搜索中禁用字典嗎?
ex。移動 - >變成mov,我的搜索失敗了。
任何想法如何索引非語言詞彙?
謝謝!
您是否嘗試過帶空停止詞文件的simple
字典?
創建一個空的停用詞文件$(pg_config --sharedir)/tsearch_data/empty.stop
並運行:
CREATE TEXT SEARCH DICTIONARY machine (
TEMPLATE = pg_catalog.simple,
STOPWORDS = empty
);
CREATE TEXT SEARCH CONFIGURATION machine (
PARSER = default
);
ALTER TEXT SEARCH CONFIGURATION machine
ADD MAPPING FOR asciiword, word, numword, asciihword, hword,
numhword, hword_asciipart, hword_part,
hword_numpart, email, protocol, url, host,
url_path, file, sfloat, float, int, uint,
version, tag, entity, blank
WITH machine;
然後你就可以得到:
test=> SELECT * FROM ts_debug('machine', 'move');
alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+-------+--------------+------------+---------
asciiword | Word, all ASCII | move | {machine} | machine | {move}
(1 row)
如果你想在默認情況下此配置(這樣你就不必指定'machine'
始終),請適當更改參數default_text_search_config
。
謝謝!只是懷疑,這將與XML領域的工作? –
這應該適用於XML。 –