XQuery/重新索引集合
外观
< XQuery
您需要一个命令行函数来重新索引集合。
我们将使用一个 Apache Ant 任务,它将调用一个 XQuery 脚本,该脚本将运行重新索引 XQuery 函数。
<target name="reindex-faqs">
<property name="server-uri" value="xmldb:exist://127.0.0.1:8080/xmlrpc"/>
<property name="collection" value="/db/dan/apps/faqs/data"/>
<echo message="Reindexing collection ${collection}"/>
<echo message="on server-uri = ${server-uri}"/>
<xdb:xquery uri="${server-uri}/db"
user="admin" password="myadminpw"
outputproperty="result">
xquery version "1.0";
let $start-time := util:system-time()
let $reindex := xmldb:reindex('/db/dan/apps/faqs/data')
let $end-time := util:system-time()
let $runtimems := (($end-time - $start-time) div xs:dayTimeDuration('PT1S')) * 1000
return $runtimems
</xdb:xquery>
<echo message="Reindex performed in = ${result} milliseconds."/>
</target>
要运行该命令,只需使用 ant 命令。
$ant reindex-faqs
Buildfile: build.xml reindex-faqs: [echo] Reindexing collection /db/dan/apps/faqs/data [echo] test server = xmldb:exist://127.0.0.1/xmlrpc [xdb:xquery] Database driver registered. [xdb:xquery] Found 1 results [echo] Reindex performed in = 203 milliseconds. BUILD SUCCESSFUL Total time: 1 second
这应该在 Windows 和 UNIX 系统上都能工作。