Roberto Pozzi
Roberto Pozzi

Reputation: 77

How to query Cloudant documents for a specific field

I am new to Cloudant and I need to do a simple query on a specific document field. My documents have the following structure and I need to get only the documents with status=SIGNED

{
  "_id": "3ddb4058f3b24a7a9c585f997e30ff78",
  "_rev": "3-757c82c48f4e7c333911be6859aff74e",
  "fileName": "Generali Architects",
  "status": "SIGNED",
  "user": "italy",
  "_attachments": {
    "Generali Architects": {
      "content_type": "application/pdf",
      "revpos": 3,
      "digest": "md5-9hqSif7CzQ2yvKxSSbj+dw==",
      "length": 323653,
      "stub": true
    }
  }
}

Reading Cloudant documentation I created the following Design Document with a related view which returns exactly what I expected Cloudant View

Then from my Java application I use the following code

        String cloudantView = "_design/signedDocs/status-signed-iew";
     List<SignDocDocument> docs =  

db.view(cloudantView).includeDocs(true).query(SignDocDocument.class);

which always returns me "org.lightcouch.NoDocumentException: Object Not Found"

Any idea which kind of mistake I am making here?

Thank you very much

Upvotes: 1

Views: 849

Answers (1)

SimonM
SimonM

Reputation: 116

Is it the typo in "_design/signedDocs/status-signed-iew"; e.g. that should be "_design/signedDocs/status-signed-view"; (depending on how your java library works...).

Always worth checking the view by direct access in your browser, too, just to make sure it's returning the expected data.

Upvotes: 1

Related Questions