Apache Ant/Reindex a Collection

MotivationEdit

You want a simple ant task that will reindex a collection.

MethodEdit

We will us the ant task that will call an XQuery that has the reindex() command in it. Because there is no ant task that does this we will use the xquery task to execute a remote XQuery that performs this task.

Here is a link to the ant task to run an XQuery http://exist-db.org/ant-tasks.html#N1041F

Call a remote XQuery by file nameEdit

<target name="reindex-collection">
    <xdb:xquery user="${user}" password="${password}"
        uri="${test-server}$(collection)" query="reindex.xq"
        outputproperty="result">
     </xdb:xquery>
     <echo message="Result = ${result}"/>
</target>

Supply the Body of an XQueryEdit

<target name="inline-query">
   <xdb:xquery uri="${test-server}/db"  
       user="${user}" password="${password}"
       outputproperty="result">
       reindex('/db/mycollection')
     </xdb:xquery>
     <!-- note, this only returns a SINGLE line -->
     <echo message="Result = ${result}"/>
</target>