在具有 Tijah 扩展的 XQuery 中连接元素和分数列表,无需使用递归函数

发布于 2024-08-16 02:26:20 字数 795 浏览 3 评论 0原文

对于大学搜索引擎项目,我使用带有 Tijah 扩展的 MonetDB。我有一个从搜索字符串返回的节点列表:

let $qid := tijah:queryall-id($nexi)
let $nodes := tijah:nodes($qid)

$nodes 现在包含一个元素列表,例如:

<book>Design Patterns</book>
<book>AntiPatterns</book>

我可以使用以下 FLWOR 表达式计算并返回该列表的分数:

for $book in $nodes
  let $score := tijah:score($qid, $book)
  order by $score descending
  return <book score="{$score}">{$book/title}</book>

但是,我想在新的搜索查询中使用节点列表。为此,我必须从此列表中生成具有以下格式的字符串:

Design Patterns {0.2937} Antipatterns {0.43984}

在此格式中,分数(由 tijah:score 返回)和名称组合在一起。我想使用以下格式生成此字符串:递归函数,但我需要使用的 MonetDB 代数引擎不支持递归函数,

我可以使用非递归(可能是 FLWOR)表达式生成相同的结果吗?

For a university search engine project, I am using MonetDB with Tijah extensions. I've got a list of nodes, returned from a search string:

let $qid := tijah:queryall-id($nexi)
let $nodes := tijah:nodes($qid)

$nodes now contains a list of elements, e.g.:

<book>Design Patterns</book>
<book>AntiPatterns</book>

I can calculate and return the scores for this list with the following FLWOR expression:

for $book in $nodes
  let $score := tijah:score($qid, $book)
  order by $score descending
  return <book score="{$score}">{$book/title}</book>

However, I want to use the list of nodes in a new search query. To do this, I have to generate a string from this list with the following formatting:

Design Patterns {0.2937} Antipatterns {0.43984}

In this formatting the scores (returned by tijah:score and the names are combined. I wanted to generate this string with a recursive function, but the MonetDB Algebra engine I need to use doesn't support recursive functions.

Can I generate the same result with a non-recursive (possibly FLWOR) expression?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唱一曲作罢 2024-08-23 02:26:21

这是你想要的吗?

string-join(
  for $book in $nodes
  let $score := tijah:score($qid, $book)
  order by $score descending
  return string-join((data($book/title), ' {', $score, '}'), ''),
  ' ')

Does this do what you want?

string-join(
  for $book in $nodes
  let $score := tijah:score($qid, $book)
  order by $score descending
  return string-join((data($book/title), ' {', $score, '}'), ''),
  ' ')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文