我有這樣一個map()函數在啤酒設計文檔:Couchbase查詢「 uefff」打破了一個條件鍵
function (doc, meta) {
if(doc.brewery_id)
emit([ doc.brewery_id, doc.abv], [doc.name, doc.abv, doc.type, doc.brewery_id, doc.style, doc.category]);
}
我需要把所有的文檔與2個規則:
1. [brewery_id]開始與 「21」
2 ABV] 3-4
之間
我的過濾器是:startkey=["21st", 3]
endkey=["21st\uefff", 4]
但結果不正確,規則1按預期工作,但規則2被忽略。 請幫我看看有什麼不對。
謝謝!
聽的結果
{"total_rows":5891,"rows":[
{"id":"21st_amendment_brewery_cafe-bitter_american","key":["21st_amendment_brewery_cafe",3.6],"value":["Bitter American",3.6,"beer","21st_amendment_brewery_cafe","Special Bitter or Best Bitter","British Ale"]},
{"id":"21st_amendment_brewery_cafe-563_stout","key":["21st_amendment_brewery_cafe",5],"value":["563 Stout",5,"beer","21st_amendment_brewery_cafe","American-Style Stout","North American Ale"]},
{"id":"21st_amendment_brewery_cafe-south_park_blonde","key":["21st_amendment_brewery_cafe",5],"value":["South Park Blonde",5,"beer","21st_amendment_brewery_cafe","Golden or Blonde Ale","North American Ale"]},
{"id":"21st_amendment_brewery_cafe-amendment_pale_ale","key":["21st_amendment_brewery_cafe",5.2],"value":["Amendment Pale Ale",5.2,"beer","21st_amendment_brewery_cafe","American-Style Pale Ale","North American Ale"]},
{"id":"21st_amendment_brewery_cafe-potrero_esb","key":["21st_amendment_brewery_cafe",5.2],"value":["Potrero ESB",5.2,"beer","21st_amendment_brewery_cafe","Special Bitter or Best Bitter","British Ale"]},
{"id":"21st_amendment_brewery_cafe-general_pippo_s_porter","key":["21st_amendment_brewery_cafe",5.5],"value":["General Pippo's Porter",5.5,"beer","21st_amendment_brewery_cafe","Porter","Irish Ale"]},
{"id":"21st_amendment_brewery_cafe-watermelon_wheat","key":["21st_amendment_brewery_cafe",5.5],"value":["Watermelon Wheat",5.5,"beer","21st_amendment_brewery_cafe","Belgian-Style Fruit Lambic","Belgian and French Ale"]},
{"id":"21st_amendment_brewery_cafe-north_star_red","key":["21st_amendment_brewery_cafe",5.8],"value":["North Star Red",5.8,"beer","21st_amendment_brewery_cafe","American-Style Amber/Red Ale","North American Ale"]},
{"id":"21st_amendment_brewery_cafe-oyster_point_oyster_stout","key":["21st_amendment_brewery_cafe",5.9],"value":["Oyster Point Oyster Stout",5.9,"beer","21st_amendment_brewery_cafe","American-Style Stout","North American Ale"]},
{"id":"21st_amendment_brewery_cafe-21a_ipa","key":["21st_amendment_brewery_cafe",7.2],"value":["21A IPA",7.2,"beer","21st_amendment_brewery_cafe","American-Style India Pale Ale","North American Ale"]}
]
}
可能的[couchbase中的複合視圖]的副本(http://stackoverflow.com/questions/17076267/composite-views-in-couchbase)。看到我的答案是Filipe Manana的解釋。簡短的回答:couchbase在視圖中只有一個索引,但你嘗試使用2. – m03geek
我不這麼認爲,因爲[link](http://www.couchbase.com/docs/couchbase-manual-2.0/我們可以看到?startkey = [「carrot」,0]&endkey = [「carrot」,20],該過濾器基於2個字段 – Phillip
不可以。不瞭解我。在?startkey = [「carrot」,0]&endkey = [「carrot」,20]中,第一個參數在兩個鍵中都是相等的。在你的例子中,你嘗試使用2個範圍,即?startkey = [「carrot-1」,0]和endkey = [「carrot-20」,20]。這是兩件不同的事情。我給了你一個同樣問題的鏈接。如果你仔細閱讀並按照Filipe的答案鏈接,你會明白爲什麼它是兩個不同的東西。 – m03geek