Mercurial > hg > mpdl-group
comparison software/eXist/webapp/mpdl/_stuff/oxygen-projects/monte-project/lucene/search.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:2396a569e446 | 7:5589d865af7a |
---|---|
1 xquery version "1.0"; | |
2 | |
3 module namespace mpdl-lucene = "http://www.mpiwg-berlin.mpg.de/ns/mpdl/lucene/search"; | |
4 | |
5 declare namespace ft = "http://exist-db.org/xquery/lucene"; | |
6 | |
7 declare function mpdl-lucene:search($docPath, $ftQuery) as node() { | |
8 let $document := doc($docPath) | |
9 (: performance reasons: all hits (not only the first 10! ) are passed through the :) | |
10 (: for loop: so the overhead in each loop has to be minimized :) | |
11 let $t := $document//s[ft:query(., $ftQuery)] | |
12 let $tempQueryResult := | |
13 for $ss at $poss in $t | |
14 (: where $poss > 100 and $poss <= 200 :) | |
15 return $ss | |
16 let $queryResult := | |
17 for $s at $pos in $tempQueryResult | |
18 let $pnOfS := count($document//pb[. << $s]) (: faster: comparison only in pb elements of this document :) | |
19 let $posOfS := count($document//pb[$pnOfS]/following::s[. << $s]) + 1 (: faster: comparisonon only in s elements of this document :) | |
20 let $resultElem := | |
21 <hit> | |
22 <pos>{$pos}</pos> | |
23 <pn>{$pnOfS}</pn> | |
24 <pos-of-s>{$posOfS}</pos-of-s> | |
25 {$s} | |
26 </hit> | |
27 return $resultElem | |
28 let $resultSize := count($queryResult) | |
29 let $result := | |
30 <ft-query> | |
31 <name>{$ftQuery}</name> | |
32 <result> | |
33 <size>{$resultSize}</size> | |
34 <hits> | |
35 {$queryResult} | |
36 </hits> | |
37 </result> | |
38 </ft-query> | |
39 return $result | |
40 }; |