Changeset 830 for MDRepository


Ignore:
Timestamp:
11/02/10 12:06:47 (14 years ago)
Author:
vronk
Message:

introducing init-cache.xql,
proposing search-retrieve queries in the test-suite

Location:
MDRepository/trunk/xquery
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • MDRepository/trunk/xquery/cmd-model.xqm

    r827 r830  
    7171  API function searchRetrieve.
    7272:)
    73 declare function cmd-model:search-retrieve($cql-query as xs:string, $collections as xs:string+, $format as xs:string, $start-item as xs:integer, $end-item as xs:integer) as item()* {
    74   let $collection := collection($cmd-model:cmdiMirrorPath),
    75     $decoded-query := xdb:decode($cql-query),
     73declare function cmd-model:search-retrieve($xpath-query as xs:string, $collections as xs:string+, $format as xs:string, $start-item as xs:integer, $end-item as xs:integer) as item()* {
     74  let $start-time := fn:current-dateTime(),
     75  $collection := collection($cmd-model:cmdiMirrorPath),
     76    $decoded-query := xdb:decode($xpath-query),
    7677    $sanitized-query := cmd-model:sanitize-query($decoded-query),
    7778    $results :=
     
    8485    $result-seq := fn:subsequence($results, $start-item, $end-item),
    8586    $seq-count := fn:count($result-seq),
     87    $end-time := fn:current-dateTime(),
    8688    $result-fragment :=
    8789    <searchRetrieveResponse>
    8890      <numberOfRecords>{$result-count}</numberOfRecords>
    89       <echoedSearchRetrieveRequest>{if ($decoded-query ne $sanitized-query) then "Rewritten to descendant-or-self::CMD" else $cql-query, $collections, $start-item, $end-item}</echoedSearchRetrieveRequest>
    90       <diagnostics>{$seq-count}</diagnostics>
     91      <echoedSearchRetrieveRequest>{if ($decoded-query ne $sanitized-query) then "Rewritten to descendant-or-self::CMD" else $xpath-query, $collections, $start-item, $end-item}</echoedSearchRetrieveRequest>
     92      <extraResponseData>
     93                <returnedRecords>{$seq-count}</returnedRecords>
     94                <duration>{$end-time - $start-time}</duration>
     95      </extraResponseData>
    9196      <records>
    9297        {$result-seq}
  • MDRepository/trunk/xquery/cmd-test.xml

    r827 r830  
    3131                                                import module namespace cmd-model = "http://spraakbanken.gu.se/clarin/xquery/model"
    3232                                                                        at "xmldb:exist:///db/clarin/cmd-model.xqm";
    33                                                 cmd-model:query-model('Components', '/db/cmdi-mirror', 'xml', 1)
     33                                                cmd-model:query-model('Components', 'root', 'xml', 1)
    3434                                                                </xquery>
    3535                        </sequence>
     
    3939                <group name="cmdi-tests-searchRetrieve">
    4040                                <thread name="thread1" connection="con">
    41             <sequence repeat="20" description="query imdi resources (no index)">             
    42                                         <xquery collection="/db/cmdi-mirror" query=""></xquery>
     41            <sequence repeat="20" description="actual queries on the mdrecords">             
     42                                        <xquery collection="/db/cmdi-mirror" query="">
     43                                                import module namespace cmd-model = "http://spraakbanken.gu.se/clarin/xquery/model"
     44                                                                        at "xmldb:exist:///db/clarin/cmd-model.xqm";
     45                                                 cmd-model:search-retrieve("//title[contains(.,'a')]", 'root', 'xml', 1,10)
     46                                        </xquery>
     47                                        <xquery collection="/db/cmdi-mirror" query="//ft:query(*, <query><term>Language</term></query>)" />
     48                                        <xquery collection="/db/cmdi-mirror" query="ft:query(descendant::IsPartOf, <query><term>clarin-at:aac-test-corpus</term></query>)" />
     49                                        <xquery collection="/db/cmdi-mirror" query="//idno[.='4197']" />
     50                                        <xquery collection="/db/cmdi-mirror" query="//date[.>'1920']" />
     51                                        <xquery collection="/db/cmdi-mirror" query="//ResourceType[.='Metadata']" />
     52                                        <xquery collection="/db/cmdi-mirror" query="//sourceDesc/biblStruct/monogr/title[contains(.,'rat')]" />
     53                                        <xquery collection="/db/cmdi-mirror" query="//CMD/*[.//teiHeader//monogr/title[contains(.,'t')]][.//teiHeader//imprint/date[.>'1930']][.//teiHeader//imprint/date[.<'1935']]" />                                       
    4354                        </sequence>
    4455                                </thread>
Note: See TracChangeset for help on using the changeset viewer.