IBM DB2 TextSearch // Language = AUTO // 语言处理
IBM DB2 TextSearch // Language = AUTO // Linguistic processing
我在 Windows 服务器 32 位上使用最新版本的 IBM DB2 Express-C 版 LUW。
TextSearch-Engine 已正确配置并且目前可以正常工作。
我创建了一个小测试 table,其中包含一个主键 id 列和一个 varchar 列。 varchar 列定义为全文索引。
db2ts "CREATE INDEX db2admin.test_id_dx FOR TEXT ON test(anytext) LANGUAGE AUTO CONNECT TO M2FDEVTS USER xxx USING yyy"
如您所见,我将语言参数设置为 AUTO。
检查索引配置
SELECT * FROM sysibmts.tsindexes
第 "language" 列设置为自动。
为了安全起见,我也将全局配置设置为 AUTO。我用
检查过
SELECT * FROM sysibmts.TSDEFAULTS
我的问题:
我无法确定将文本放入 table 时使用的是哪种语言。所以我插入了包含德语和英语内容的行。内容未混排。
更新索引后我做了一些查询。
SELECT SUBSTR(anytext,1,30) FROM test WHERE CONTAINS(anytext, 'spiele', 'QUERYLANGUAGE = de_DE') = 1
首先,我创建了语言模式=自动的索引。单词 "spiele" 不是全文列中任何文本的一部分。不过想到db2全文索引的语言处理,应该是有命中的。但是一点结果也没有。
之后,我删除了索引并使用语言 de_DE 重新创建了它。更新索引后,我再次触发相同的查询 - 现在返回一些结果行!
怎么了?使用 language=auto 和 language=de_DE 创建索引之间显然存在差异。我研究了文档。它清楚地写着:
The locale that you specify in yourdb2ts CREATE INDEXcommand determines
the language used to tokenize or analyze documents for indexing. If you know
that all documents in the column to be indexed use a specific language, specify
the applicable locale when you create the text search index. If you do not specify
a locale, the database territory will be used to determine the default setting for
LANGUAGE. To have your documents automatically scanned to determine the
locale, in the SYSIBMTS.TSDEFAULTS view, set the LANGUAGEattribute toAUTO.
The SYSIBMTS.TSDEFAULTS view describes database defaults for text search
using attribute-value pairs.
非常感谢您的帮助!
奥利弗
好的,解决方法很简单。我用来测试的句子太短了。在这种情况下,DB2 无法确定选择哪种语言进行标记化。
建立索引,根据正确的语言或使用词数较多的句子,查询结果符合预期。
奥利弗
我在 Windows 服务器 32 位上使用最新版本的 IBM DB2 Express-C 版 LUW。
TextSearch-Engine 已正确配置并且目前可以正常工作。
我创建了一个小测试 table,其中包含一个主键 id 列和一个 varchar 列。 varchar 列定义为全文索引。
db2ts "CREATE INDEX db2admin.test_id_dx FOR TEXT ON test(anytext) LANGUAGE AUTO CONNECT TO M2FDEVTS USER xxx USING yyy"
如您所见,我将语言参数设置为 AUTO。
检查索引配置
SELECT * FROM sysibmts.tsindexes
第 "language" 列设置为自动。
为了安全起见,我也将全局配置设置为 AUTO。我用
检查过SELECT * FROM sysibmts.TSDEFAULTS
我的问题:
我无法确定将文本放入 table 时使用的是哪种语言。所以我插入了包含德语和英语内容的行。内容未混排。
更新索引后我做了一些查询。
SELECT SUBSTR(anytext,1,30) FROM test WHERE CONTAINS(anytext, 'spiele', 'QUERYLANGUAGE = de_DE') = 1
首先,我创建了语言模式=自动的索引。单词 "spiele" 不是全文列中任何文本的一部分。不过想到db2全文索引的语言处理,应该是有命中的。但是一点结果也没有。
之后,我删除了索引并使用语言 de_DE 重新创建了它。更新索引后,我再次触发相同的查询 - 现在返回一些结果行!
怎么了?使用 language=auto 和 language=de_DE 创建索引之间显然存在差异。我研究了文档。它清楚地写着:
The locale that you specify in yourdb2ts CREATE INDEXcommand determines the language used to tokenize or analyze documents for indexing. If you know that all documents in the column to be indexed use a specific language, specify the applicable locale when you create the text search index. If you do not specify a locale, the database territory will be used to determine the default setting for LANGUAGE. To have your documents automatically scanned to determine the locale, in the SYSIBMTS.TSDEFAULTS view, set the LANGUAGEattribute toAUTO. The SYSIBMTS.TSDEFAULTS view describes database defaults for text search using attribute-value pairs.
非常感谢您的帮助! 奥利弗
好的,解决方法很简单。我用来测试的句子太短了。在这种情况下,DB2 无法确定选择哪种语言进行标记化。
建立索引,根据正确的语言或使用词数较多的句子,查询结果符合预期。
奥利弗