多云搜索过滤不起作用,为什么?

时间:2014-11-25 06:06:36

标签: cloudant

在这里,我引用了我的代码进行多次搜索过滤。我找不到那个错误。请提供正确的代码,以使其运作良好。

员工文件:

{   “_id”:“527c8d9327c6f27f17df0d2e17000530”,

“_ rev”:“24-276a8dc913559901897fd601d2f9654f”,

“proj_role”:“TeamMember”,

“work_total_experience”:“3”,

“personal”:{   “languages_known”:[    “英语”,“泰卢固语” ]},

“技能”:[

{

  "skill_set": "Webservices Framework",
  "skill_exp": 1,
  "skill_certified": "yes",
  "skill_rating": 3,
},
{
 "skill_set": "Microsoft",
  "skill_exp": 1,
  "skill_certified": "yes",
  "skill_rating": 3,
}

]
  “framework_competency”:“Nasscom”,   “type”:“employee-docs” }

设计文件:

{   “_id”:“_ design / sample”,

“_ rev”:“86-1250f792e6e84f6f33447a00cf64d61d”,

“观看次数”:{},

“语言”:“javascript”,

“索引”:{

"search": {

  "index": "function(doc){\n index(\"default\", doc._id);if(doc.type=='employee-docs'){\nif (doc.proj_role){index(\"project_role\", doc.proj_role);}if(doc.work_total_experience){\nindex(\"work_experience\", doc.work_total_experience);}\nif(doc.personal.languages_known){for(c in doc.personal.languages_known){ \n index(\"languages_known\",doc.personal.languages_known[c]);}} if(doc.skills){for (var i=0;i<doc.skills.length;i++){\nindex('skill_set',doc.skills[i].skill_set);}}}}"

}

} }

使用以下网址运行:https://ideyeah4.cloudant.com/opteamize_new/_design/sample/_search/search?q=project_role:TeamMember%20AND%20work_experience:%223%22%20AND%20languages_known:Telugu%20AND%20skill_set:Microsoft&include_docs=true

1 个答案:

答案 0 :(得分:1)

调试此方法的一种简单方法是查询索引中的前100个结果:

https://ideyeah4.cloudant.com/opteamize_new/_design/sample/_search/search?q=*:*&limit=100

这至少会告诉你索引中是否有任何文件。

您当前的查询(没有网址编码)如下所示:

project_role:TeamMember AND work_experience:"3" AND languages_known:Telugu AND skill_set:Microsoft

我建议其中一些搜索值需要引号 - 在搜索字符串值时始终为true。接下来,您可以尝试:

project_role:"TeamMember"

看看你是否得到了任何结果并从那里进行了改进。

如果您存储值以及对它们进行索引,那么调试它可能也会更容易(因此您可以准确地查看索引的内容)。为此,请将对象添加到每个索引调用{“store”:true}。例如,

index("languages_known", doc.personal.languages_known[c], { "store": true });

现在,当您查询索引时,它将返回每个匹配项存储的字段列表。