views:

106

answers:

1

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 FLOWR 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 FLOWR) expression?

A: 

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, '}'), ''),
  ' ')
Oliver Hallam