Is there a way to get only conflicts in CBL 1.3

Is it possible to get only documents that have conflicts view the REST API in CBL 1.3. Can’t see anything in the docs, there used to be a conflicts_only parameter somewhere but I could never get it to work.

All is can see is that query view and all_docs allow you to return conflicts. But I was after a way of finding all conflicting documents.

If it’s not in the API could it be achieved with a custom view?

This is for Android running on the local database. Is this what your are after?

Query query = database.createAllDocumentsQuery();
query.setAllDocsMode(Query.AllDocsMode.ONLY_CONFLICTS);
QueryEnumerator result;
try {
    result = query.run();
    for (Iterator<QueryRow> it = result; it.hasNext(); ) {
        QueryRow row = it.next();
        if (row.getConflictingRevisions().size() > 0) {
            final Document doc = database.getDocument(row.getDocumentId());
            final List<SavedRevision> conflicts = doc.getConflictingRevisions();
            resolveConflicts(doc, conflicts);
        }
    }
} catch (CouchbaseLiteException e) {
    e.printStackTrace();
}

No, I meant for the REST API, sorry wasn’t clear in my question.

This answer How to get conflicts is exactly what you’re looking for. You can create a view that emits only if the doc._conflicts property isn’t null.

James

I think maybe the only_conflicts parameter on _all_docs has been implemented on android now, and removed from the documentation for some reason. Is that right?

@hideki looks like the REST parameter is implemented in iOS and maybe Android, but not documented? Can you confirm?

Reference issue https://github.com/couchbase/couchbase-lite-java-core/issues/1211

Thanks,
Hod

only_conflicts and include_conflicts query parameters for _all_docs REST API is available with CBL Android/Java v1.3.0 or higher

Is there a reason isn’t not documented? Is it ok to use?

Is it ok to use?

YES