1

This is the my document which i store in the bucket.Also the Id(key) attribute is screenName.

{
       "created": null,
       "createdBy": null,
       "updated": null,
       "updatedBy": null,
       "screenName": "steelers",
       "appId": "100",
       "domain": "100$APPINFOTEAM",
       "alias": "steelers",
       "devision": "1"
   }

I have multiple documents in Couchbase in this format. So i need to fetch these documents in descending order. So this is the implementation I used it for,

        Query query = new Query();
        // Filter on the domain key
        query.setIncludeDocs(true);
        query.setDescending(true);
        query.setInclusiveEnd(true);
        query.setKey(domain);
        List<AppInfoTeam> appInfoTeam = appinfoTeamService.getAppInfoTeamForApp(query);

This will give me the exact documents without sorting. This is my view

function (doc, meta) {
if (doc._class == "com.link.twitter.pojo.AppInfoTeam") {
    emit(doc.domain, null);
  }
}

Also I tried to Filter Results using Couchbase server interface. I tick the descending and inclusive_end values. Also put the domain as a key. Then when I click the show results button it will give me this error.

url: ?stale=false&descending=true&inclusive_end=true&key=domain&connection_timeout=60000&limit=10&skip=0

Error:

{"error":"bad_request","reason":"invalid UTF-8 JSON: {{error,{1,\"lexical error: invalid char in json text.\\n\"}},\n                     \"domain\"}"}

How can I fix this issue?

DaveR
  • 9,540
  • 3
  • 39
  • 58
Neero
  • 226
  • 2
  • 7
  • 23

1 Answers1

4

You need to wrap the key with double quotes:

<url>?stale=false&descending=true&inclusive_end=true&key="domain"&connection_timeout=60000&limit=10&skip=0
FuzzyAmi
  • 7,543
  • 6
  • 45
  • 79
  • you might have to escape the quotes - so try this too: \"domain\" – FuzzyAmi Aug 15 '15 at 12:30
  • Thanks for the suggestions.I tried both ways but its not working. Also I want to implement this in my code not in Couchbase server interface. – Neero Aug 17 '15 at 15:57
  • I can't help you with the java part of it, but in general getting your query right on the ui is good way (and usually faster) than doing it in code. I went back to my setup and this query works - note how I escaped the key http://:8092/groups/_design/dev_groups/_view/groupid_by_fbuserid?stale=false&inclusive_end=true&connection_timeout=60000&limit=10&skip=0&key=%22123%22 are you still getting the same error? what happens when you click on the url thats show in the view page UI (next to the 'filter results' text)? – FuzzyAmi Aug 17 '15 at 17:07
  • You get the same error when running the test url on the View design page: ?stale=false&inclusive_end=true&connection_timeout=60000&limit=10&skip=0 – kruthar Aug 20 '15 at 02:48
  • No it happens only when I add the key. – Neero Aug 20 '15 at 17:02