Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

viewquery is empty first time #106

@anna-b

Description

@anna-b

When I query the view for the first time, it returns nothing. But if I query for the second time - everything is fine.
There is a difference in the LogCat info:

-- first time --

08-09 11:07:45.717: V/TDDatabase(18423): Re-indexing view findUserInfo/findByType ...
08-09 11:07:45.717: V/TDDatabase(18423): Query findMeetingAssets/findByType: SELECT key, value, docid FROM maps, revs, docs WHERE maps.view_id=? AND revs.sequence = maps.sequence AND docs.doc_id = revs.doc_id ORDER BY key LIMIT ? OFFSET ?

-- second time --

08-09 11:07:45.727: V/TDDatabase(18423): Re-indexing view findUserInfo/findByType ...
08-09 11:07:45.727: V/TDDatabase(18423): call map for sequence=1
08-09 11:07:45.727: V/TDDatabase(18423): call map for sequence=61
08-09 11:07:45.727: V/TDDatabase(18423): ...Finished re-indexing view findUserInfo/findByType up to sequence 61 (deleted 0 added ?)

this "call map for sequence" seems to make things work, how can I make it so that I receive the data with the first request?

Here is the view:
createViewUser(Consts.DOCUMENT_TYPE_USERINFO, requestNumber, Consts.FIND_DOCUMENT_USERINFO);

private void createViewUser(final String typeName, String mapRequestNumber, final String docName) {

TDView view = localDbUser.getViewNamed(String.format("%s/%s", docName, Consts.FIND_BY_TYPE));

view.setMapReduceBlocks(new TDViewMapBlock() {

@OverRide

public void map(Map<String, Object> document, TDViewMapEmitBlock emitter) {

String type = (String) document.get("type");

if (typeName.equals(type)) {

emitter.emit(null, document);

}

}

}, null, mapRequestNumber);

}

Here is the view query:
ViewQuery query = new ViewQuery().designDocId(Consts.D_DOC_ID + Consts.FIND_DOCUMENT_USERMEETING).viewName(Consts.FIND_BY_TYPE);

ViewResult viewResult = mCouchDbConnectorUser.queryView(query);

List listRowsMeetings = viewResult.getRows();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions