MarkLogic 中的本地化

标签 localization wildcard marklogic

我在 MarkLogic(在 7.0-1 上测试) 中进行本地化和通配符搜索时遇到问题。

示例:

let $x := 
<root>
<el xml:lang="en">hello</el>
<el xml:lang="fr">hello</el>
</root>

return
$x//el[cts:contains(., cts:word-query("hello*", ("wildcarded", "lang=fr")))]

为什么它返回两个元素 el 而不仅仅是一个带有 xml:lang="fr"的元素? 当我从 "hello*" 中删除星号时,它只返回一个元素符合预期。

如何在通配符搜索中使用本地化?

最佳答案

MarkLogic 使用与语言相关的索引进行词干搜索,但不使用非词干搜索。不幸的是,通配符搜索是针对与语言无关的无词干索引执行的。

该部分'Language-Aware Searches' Search Dev Guide的解释了语言感知在 MarkLogic 中的工作原理并指出:

All searches use the language setting in the cts:query constructor to determine how to tokenize the search terms. Stemmed searches also use the language setting to derive stems. Unstemmed searches use the specified language for tokenization but use the unstemmed (word searches) indexes, which are language-independent.

以及'Interaction with Other Search Features'部分直接关联通配符和词干搜索,并指出:

The system will not perform a stemmed search on words that are wildcarded.

我认为你基本上有两个选择:

  • 您可以事后手动过滤,但这可能会因错误语言的误报而导致估计值过高。

  • 或者,您可以使用单词词典来查找显式值,并将其作为序列传递给您的 cts:word-query。

类似于:

let $x := 
<root>
<el xml:lang="en">hello</el>
<el xml:lang="fr">hello</el>
</root>

return
$x//el[cts:contains(., cts:word-query(cts:words("hell"), ("lang=fr")))]

请注意,后者确实需要您启用单词词典,并且 cts:words 返回的值来自数据库中的文档。

呵呵!

关于MarkLogic 中的本地化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24930223/

相关文章:

c# - 有没有办法从 C# CultureInfo 获取标志图像?

javascript - 如何关闭 Google reCAPTCHA 本地化或锁定为英语

图像源中的 jQuery 通配符

marklogic - 如何从marklogic中的xml文档中获取json结果

marklogic - 如何使用mlgradle在MarkLogic部署中配置Taskserver 'max time limit'?

c# - 在 C# 中从 CurrentCulture 中查找流向

php - PHP Intl 扩展线程安全吗?

apache - 将子域转发到子文件夹并保留子文件夹的 .htaccess mod_rewrite 规则

java - 区分apache Camel中使用通配符时调用的是哪个队列

sql - 返回xdmp :sql() values in CSV format XQuery