Reputation: 5771
Is there an easy way to delete all the element range indexes on a given database?
Thanks
Upvotes: 1
Views: 165
Reputation: 11244
You could write some script to do this, for example in JavaScript which you need to execute from your Query Console:
'use strict';
const admin = require('/MarkLogic/admin');
const config = admin.getConfiguration();
const db = xdmp.database('Documents');
const indexes = admin.databaseGetRangeElementIndexes(config, db);
const newConfig = admin.databaseDeleteRangeElementIndex(config, db, indexes);
admin.saveConfiguration(newConfig);
'All Range Indexes have been removed.'
The above goes through all the Element Range Indexes for the 'Documents' database and removes them - including any pre-defined Range Indexes for DLS.
Upvotes: 1
Reputation: 666
I believe you can do this using the REST Management API method PUT /manage/v2/databases/{dbid}/properties
. If you pass a payload in which the range-element-indexes
property is empty, I think it removes any existing ones.
Take a look at the following:
http://docs.marklogic.com/REST/PUT/manage/v2/databases/[id-or-name]/properties
You'd want to use a payload similar to the following for XML:
<database-properties xmlns="http://marklogic.com/manage">
<range-element-indexes/>
</database-properties>
Or like this for JSON:
{ "range-element-index": [] }
Be careful, though: It's a sharp tool. You'll also delete pre-defined indexes like the ones for DLS. I think that's also true of Tamas' solution, but did not confirm.
Upvotes: 1