1

I am using couchdb for first time but I am facing a problem that I cannot find how to solve. I am creating an ad-hoc view with the following line

ViewResults resultAdHoc = db.adhoc("function(doc) {emit(null, doc.name);}");

when I am running the function with futon I am getting the names in the value side, so I guess it is correctly written. The form of one document is the following

{
   "_id": "d11d7fa59d162658b7cc95c34a001ce0",
   "_rev": "1-a4038d7061988c7552f9b8b435bba9bf",
   "name": "MyName",
   "session": "549C6567BE25D96EA1D2553C4A9DE175"
}

This that I cannot figure out is how to read this so I could get all the names of the documents in Java for further processing (e.g. to print them);

p.s. I am using the CouchDB4J

Slartibartfast
  • 8,735
  • 6
  • 41
  • 45
x_maras
  • 2,177
  • 1
  • 25
  • 34

1 Answers1

0

I haven't tried this, but something like this should work

ViewResults resultAdHoc = db.adhoc("function(doc) {emit(null, doc.name);}");
for (Document d: resultAdHoc.getResults()) {
    String name = d.getString("value");
    ....
}
Slartibartfast
  • 8,735
  • 6
  • 41
  • 45
  • When I run it I get a pop up window and a warning message in my console: log4j:WARN No appenders could be found for logger (org.directwebremoting.util.Logger). log4j:WARN Please initialize the log4j system properly... – x_maras Oct 27 '11 at 09:29
  • That shouldn't be an issue (except you cant see error messages). See [log4j manual](http://logging.apache.org/log4j/1.2/manual.html) on how to configure logging. – Slartibartfast Oct 27 '11 at 09:38
  • is their any solution fro the above question plz post the solution as i m also facing same problem – Piyush Srivastava Jan 31 '14 at 08:05