You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Operations: How to Change the Index Lock Mode

SetIndexesLockOperation allows you to change index lock mode for a given index or indexes.

Syntax

public SetIndexesLockOperation(String indexName, IndexLockMode mode)
public SetIndexesLockOperation(SetIndexesLockOperation.Parameters parameters)

public enum IndexLockMode {
    UNLOCK,
    LOCKED_IGNORE,
    LOCKED_ERROR
}

public static class Parameters {
    private String[] indexNames;
    private IndexLockMode mode;

    public String[] getIndexNames() {
        return indexNames;
    }

    public void setIndexNames(String[] indexNames) {
        this.indexNames = indexNames;
    }

    public IndexLockMode getMode() {
        return mode;
    }

    public void setMode(IndexLockMode mode) {
        this.mode = mode;
    }
}

Parameters
name String name of an index to change lock mode for
lockMode IndexLockMode new index lock mode
parameters SetIndexesLockOperation.Parameters list of indexes + new index lock mode

Example I

SetIndexesLockOperation.Parameters parameters = new SetIndexesLockOperation.Parameters();
parameters.setIndexNames(new String[]{ "Orders/Totals", "Orders/ByCompany" });
parameters.setMode(IndexLockMode.LOCKED_IGNORE);

store.maintenance().send(new SetIndexesLockOperation(parameters));

Example II

SetIndexesLockOperation.Parameters parameters = new SetIndexesLockOperation.Parameters();
parameters.setIndexNames(new String[]{ "Orders/Totals", "Orders/ByCompany" });
parameters.setMode(IndexLockMode.LOCKED_IGNORE);

store.maintenance().send(new SetIndexesLockOperation(parameters));