I have a requirement whereby existing fields needs to be deleted. I found perfect script for deletion of field-range indexes but not for fields. So, I wrote this script which works fine but I need to pass each field-name one by one :
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
let $dbid := xdmp:database("testDB")
let $fields := admin:database-get-fields($config,$dbid)
for $each in $fields
let $config := admin:database-delete-field($config, $dbid,$each/*:field-name/fn:string())
return admin:save-configuration($config)
Does anyone else has a better solution for this? Whereby we can directly pass fields and it's done.