2015-08-14 65 views
1

這是我的文檔,我存儲在bucket.Also的ID(鍵)的屬性是屏幕名。「在JSON文本字符無效」的Couchbase觀點錯誤導致

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

我在這種格式的Couchbase中有多個文檔。所以我需要以降序獲取這些文件。所以這是我用它的實現,

 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); 

這將給我沒有排序的確切文件。這是我的看法

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

我也試過篩選結果使用Couchbase服務器接口。我打勾降序和inclusive_end值。也把域作爲關鍵。然後當我點擊顯示結果按鈕時,它會給我這個錯誤。

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

錯誤:

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

我怎樣才能解決這個問題?

回答

4

你需要用雙引號鍵:

<url>?stale=false&descending=true&inclusive_end=true&key="domain"&connection_timeout=60000&limit=10&skip=0 
+0

你可能逃跑的報價 - 那麼試試這個太:\「域\」 – FuzzyAmi

+0

感謝suggestions.I試圖左右逢源,但其不工作。另外我想在我的代碼中實現這一點,而不是在Couchbase服務器接口中。 – Neero

+0

我無法幫助您解決Java的一部分問題,但總的來說,在UI上獲得您的查詢是比在代碼中更好的方式(通常更快)。我回到我的設置和此查詢工作 - 請注意我是如何逃脫密鑰 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 你仍然得到同樣的錯誤?當你點擊鏈接,多數民衆贊成顯示(旁邊的「過濾結果」文本)視圖頁面UI會發生什麼? – FuzzyAmi

相關問題