我用荷兰语分析器在我的文档上有一些搜索索引,效果很好。例如,考虑:
http://wetten.cloudant.com/regelingen/_design/RegelingInfo/_search/regeling?q=burgerlijke
当我试图让我的搜索变得模糊时,一切都出错了:
http://wetten.cloudant.com/regelingen/_design/RegelingInfo/_search/regeling?q=burgerlijke~
一下子返回0个结果。怎么会这样?
编辑:
设计文件:
{"_id": "_design/RegelingInfo",
"_rev": "11-20993b8c49d8bcc1cd4fde58e5f40b27",
"views": {
"all": {
"map": "function(doc) { \n if (doc._id.lastIndexOf('BWB', 0) === 0 ){\n emit( null, doc._id )\n }\n}"
}
},
"lists": {},
"shows": {},
"language": "javascript", "filters": {}, "updates": {}, "indexes": {
"regeling": {
"analyzer": {
"name": "dutch",
"stopwords": ["wet", "regeling", "besluit"]
},
"index": "function(doc) {\n var globalString = new Array();\n index(\"displayTitle\", doc.displayTitle, {\"store\": \"yes\"});\n globalString.push(doc.displayTitle);\n /*index(\"officieleTitel\", doc.officieleTitel, {\"store\": \"no\"});*/\n globalString.push(doc.officieleTitel);\n /*index(\"bwbid\", doc._id);*/\n globalString.push(doc._id);\n index(\"regelingSoort\", doc.regelingSoort, {\"store\": \"no\"});\n if (doc.citeertitels) {\n for (var i = 0; i < doc.citeertitels.length; i++) {\n /*index(\"citeertitel\", doc.citeertitels[i].titel, {\"store\": \"no\"});*/\n globalString.push(doc.citeertitels[i].titel);\n }\n }\n if (doc.afkortingen) {\n for (var i = 0; i < doc.afkortingen.length; i++) {\n /*index(\"afkorting\", doc.afkortingen[i], {\"store\": \"no\"});*/\n globalString.push(doc.afkortingen[i]);\n }\n }\n if (doc.nietOfficieleTitels) {\n for (var i = 0; i < doc.nietOfficieleTitels.length; i++) {\n /*index(\"nietOfficieleTitel\", doc.nietOfficieleTitels[i], {\"store\": \"no\"});*/\n globalString.push(doc.nietOfficieleTitels[i]);\n }\n }\n if (doc.xml) {\n /* Remove tags to get inner text*/\n index(\"innerText\", doc.xml.replace(/<[^>]*>/g, \"\"), {\"store\": \"no\"});\n }\n index(\"default\", globalString.join(\" \"), {\"store\": \"no\"});\n}"
}
}}
格式化索引功能:
function(doc) {
var globalString = new Array();
index("displayTitle", doc.displayTitle, {"store": "yes"});
globalString.push(doc.displayTitle);
/*index("officieleTitel", doc.officieleTitel, {"store": "no"});*/
globalString.push(doc.officieleTitel);
/*index("bwbid", doc._id);*/
globalString.push(doc._id);
index("regelingSoort", doc.regelingSoort, {"store": "no"});
if (doc.citeertitels) {
for (var i = 0; i < doc.citeertitels.length; i++) {
/*index("citeertitel", doc.citeertitels[i].titel, {"store": "no"});*/
globalString.push(doc.citeertitels[i].titel);
}
}
if (doc.afkortingen) {
for (var i = 0; i < doc.afkortingen.length; i++) {
/*index("afkorting", doc.afkortingen[i], {"store": "no"});*/
globalString.push(doc.afkortingen[i]);
}
}
if (doc.nietOfficieleTitels) {
for (var i = 0; i < doc.nietOfficieleTitels.length; i++) {
/*index("nietOfficieleTitel", doc.nietOfficieleTitels[i], {"store": "no"});*/
globalString.push(doc.nietOfficieleTitels[i]);
}
}
if (doc.xml) {
/* Remove tags to get inner text*/
index("innerText", doc.xml.replace(/<[^>]*>/g, ""), {"store": "no"});
}
index("default", globalString.join(" "), {"store": "no"});
}