def test_return_also__fulltext_score(self): xq = Xquery(xpath='/el') xq.xq_var = '$n' xq.return_also({'fulltext_score': ''}) self.assertTrue('let $fulltext_score := ft:score($n)' in xq.getQuery()) self.assertTrue('<fulltext_score>{$fulltext_score}</fulltext_score>' in xq._constructReturn())
def test_return_also_raw(self): xq = Xquery(xpath='/el') xq.xq_var = '$n' xq._raw_prefix = 'r_' xq.return_also({'myid': 'count(util:expand(%(xq_var)s/@id))'}, raw=True) self.assertTrue('<r_myid>{count(util:expand($n/@id))}</r_myid>' in xq._constructReturn()) xq = Xquery(xpath='/el') xq.xq_var = '$n' xq._raw_prefix = 'r_' xq.return_also({'myid': '@id'}, raw=True) self.assertTrue('<r_myid>{@id}</r_myid>' in xq._constructReturn())
def test_return_also__highlight(self): xq = Xquery(xpath='/el') xq.xq_var = '$n' xq.return_also({'fulltext_score': ''}) xq.add_filter('.', 'highlight', 'dog star') self.assertTrue('(/el[ft:query(., "dog star")]|/el)' in xq.getQuery())
def test_return_also(self): xq = Xquery(xpath='/el') xq.xq_var = '$n' xq.return_also({'myid': '@id', 'some_name': 'name'}) self.assertTrue('{$n}' in xq._constructReturn()) self.assertTrue('<field>{$n/@id}</field>' in xq._constructReturn())