Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-103

Java client 1.1-dp not returning documents when querying views

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1dp
    • Fix Version/s: 1.1-beta
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None
    • Environment:
      OSX
      Couchbase Server 2.0.0dp4r-730-rel
      Java client 1.1-dp

      Description

      I'm using the Java 1.1-dp client to do queries against views. Setting query.setIncludeDocs(true) doesn't actually result in the query ViewResponse having documents (ViewRow.getDocument() returns null).

      Digging into the code, it looks like that the Query class doesn't actually set the "include_docs" parameter, nor does DocsOperationImpl.parseResult try to extract the "doc" element from the returned JSON.

      Is this deliberate? Or am I missing something? I'd really prefer not having to make a separate call to get the docs while iterating through a ViewResponse.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Tim Pedersen Tim Pedersen added a comment -

        This issue is caused when I use CouchbaseConnectionFactoryBuilder to create clients. See JCBC-102

        If I use CouchbaseConnectionFactory instead ViewRow.getDocument() returns the document correctly.
        i.e:

        URI base = new URI(String.format("http://%s:8091/pools", server));
        List<URI> baseURIs = new ArrayList<URI>();
        baseURIs.add(base);
        CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
        cfb.setOpTimeout(10000);
        cfb.setOpQueueMaxBlockTime(10000);
        CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(baseURIs, bucket, "", "");
        CouchbaseClient client = new CouchbaseClient(cf);
        //...
        View view = client.getView(myDesignDoc, myView);
        Query query = new Query();
        query.setRange(start, end);
        query.setIncludeDocs(true);
        ViewResponse viewResponse = client.query(view, query);
        for(ViewRow viewRow:viewResponse)

        { String id = viewRow.getId(); // id ok String key = viewRow.getKey(); // key ok String value = viewRow.getValue(); // value ok String doc = (String) viewRow.getDocument(); // doc is null }

        VERSUS:

        URI base = new URI(String.format("http://%s:8091/pools", server));
        List<URI> baseURIs = new ArrayList<URI>();
        baseURIs.add(base);
        CouchbaseConnectionFactory cf = new CouchbaseConnectionFactory(baseURIs, bucket, "");
        CouchbaseClient client = new CouchbaseClient(cf);
        //...
        View view = client.getView(myDesignDoc, myView);
        Query query = new Query();
        query.setRange(start, end);
        query.setIncludeDocs(true);
        ViewResponse viewResponse = client.query(view, query);
        for(ViewRow viewRow:viewResponse)

        { String id = viewRow.getId(); // id ok String key = viewRow.getKey(); // key ok String value = viewRow.getValue(); // value ok String doc = (String) viewRow.getDocument(); // doc ok }
        Show
        Tim Pedersen Tim Pedersen added a comment - This issue is caused when I use CouchbaseConnectionFactoryBuilder to create clients. See JCBC-102 If I use CouchbaseConnectionFactory instead ViewRow.getDocument() returns the document correctly. i.e: URI base = new URI(String.format("http://%s:8091/pools", server)); List<URI> baseURIs = new ArrayList<URI>(); baseURIs.add(base); CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder(); cfb.setOpTimeout(10000); cfb.setOpQueueMaxBlockTime(10000); CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(baseURIs, bucket, "", ""); CouchbaseClient client = new CouchbaseClient(cf); //... View view = client.getView(myDesignDoc, myView); Query query = new Query(); query.setRange(start, end); query.setIncludeDocs(true); ViewResponse viewResponse = client.query(view, query); for(ViewRow viewRow:viewResponse) { String id = viewRow.getId(); // id ok String key = viewRow.getKey(); // key ok String value = viewRow.getValue(); // value ok String doc = (String) viewRow.getDocument(); // doc is null } VERSUS: URI base = new URI(String.format("http://%s:8091/pools", server)); List<URI> baseURIs = new ArrayList<URI>(); baseURIs.add(base); CouchbaseConnectionFactory cf = new CouchbaseConnectionFactory(baseURIs, bucket, ""); CouchbaseClient client = new CouchbaseClient(cf); //... View view = client.getView(myDesignDoc, myView); Query query = new Query(); query.setRange(start, end); query.setIncludeDocs(true); ViewResponse viewResponse = client.query(view, query); for(ViewRow viewRow:viewResponse) { String id = viewRow.getId(); // id ok String key = viewRow.getKey(); // key ok String value = viewRow.getValue(); // value ok String doc = (String) viewRow.getDocument(); // doc ok }
        Hide
        daschl Michael Nitschinger added a comment -

        I'm also not able to reproduce this agains the master branch and the beta release of Couchbase Server 2.0 beta.

        I tested it against the beer sample, can you check if this works for you or not?

        CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
        cfb.setOpTimeout(10000);
        cfb.setOpQueueMaxBlockTime(10000);

        CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(Arrays.asList(
        URI.create("http://<HOST>:8091/pools")
        ), "beer-sample", "");

        CouchbaseClient client = new CouchbaseClient(cf);

        Query query = new Query().setIncludeDocs(true);
        View view = client.getView("beer", "brewery_beers");
        ViewResponse response = client.query(view, query);
        for(ViewRow row : response)

        { System.out.println(row.getDocument()); }

        client.shutdown();

        Show
        daschl Michael Nitschinger added a comment - I'm also not able to reproduce this agains the master branch and the beta release of Couchbase Server 2.0 beta. I tested it against the beer sample, can you check if this works for you or not? CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder(); cfb.setOpTimeout(10000); cfb.setOpQueueMaxBlockTime(10000); CouchbaseConnectionFactory cf = cfb.buildCouchbaseConnection(Arrays.asList( URI.create("http://<HOST>:8091/pools") ), "beer-sample", ""); CouchbaseClient client = new CouchbaseClient(cf); Query query = new Query().setIncludeDocs(true); View view = client.getView("beer", "brewery_beers"); ViewResponse response = client.query(view, query); for(ViewRow row : response) { System.out.println(row.getDocument()); } client.shutdown();
        Hide
        daschl Michael Nitschinger added a comment -

        Since this ticket is older and I couldn't reproduce it with the information provided, I'll close this ticket.

        If you still encounter this issue with the current release, feel free to reopen this ticket or a new one.

        Thanks,
        Michael

        Show
        daschl Michael Nitschinger added a comment - Since this ticket is older and I couldn't reproduce it with the information provided, I'll close this ticket. If you still encounter this issue with the current release, feel free to reopen this ticket or a new one. Thanks, Michael

          People

          • Assignee:
            daschl Michael Nitschinger
            Reporter:
            Tim Pedersen Tim Pedersen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes