無殼匹配我有具有以下數據結構文檔的數據庫:使用意見Cloudant
{
"_id": "sampleID",
"_rev": "sample-rev",
"added": "2014-09-09 01:05:32",
"cached": 1,
"subject": "sample topic",
"mode": "<samplemode>",
"protected": 0,
"added_by": "myname",
"factoid": "sample factoid"
}
而且我有以下看法:
function(doc) {
if (doc.subject && doc.factoid && doc.mode){
emit(doc.subject, doc.factoid);
}
}
我需要檢索的所有文檔,其中「主題」匹配提供的密鑰。我希望它不區分大小寫。 POST會給我所有我想要的比賽,但只有在比賽結果匹配的情況下。
https://<username>.cloudant.com/<db>/_design/<designdoc>/_view/<view>?include_docs=true
{ "keys" : ["<subject>"] }
我也嘗試過搜索索引沒有成功。這個API提到了一個我無法工作的regex操作符。這似乎是一件簡單的事情,我該如何處理這件事?
關於$正則表達式的方法,這裏是我在哪裏。以下POST與我之前嘗試返回區分大小寫的結果非常相似。
https://<username>.cloudant.com/<db>/_find
{
"selector": {
"subject": {"$eq": "<subject>"}
},
"fields": ["_id", "_rev", "subject", "factoid"]
}
代爲$當量一個$正則表達式運算符產生以下錯誤:
{
"error": "no_usable_index",
"reason": "There is no operator in this selector can used with an index."
}
此函數的參考材料是相當渺茫。它只是提到這個網頁上:https://docs.cloudant.com/api/cloudant-query.html
爲$正則表達式文檔的URL發生了變化,在這裏你去:https://console.bluemix.net/docs/services/Cloudant/ API /cloudant_query.html#combination-operators – Netsmile 2017-11-23 14:07:40