【发布时间】:2016-04-11 18:14:43
【问题描述】:
我已经为示例数据库建立了搜索索引,并在 cloudant 中运行搜索查询。例如,我有一个数据库:
{
"_id": "aardvark",
"_rev": "3-fe45a3e06244adbe7ba145e74e57aba5",
"min_weight": 40,
"max_weight": 65,
"min_length": 1,
"max_length": 2.2,
"latin_name": "Orycteropus afer",
"wiki_page": "http://en.wikipedia.org/wiki/Aardvark",
"class": "mammal",
"diet": "omnivore"
}
对于索引“_id”或“类”,我可以创建搜索索引:
function(doc){
index("default", doc._id);
...
}
或
function(doc){
index("default", doc.class);
...
}
但是,我不知道如何索引 Json 格式。例如,我的 Json 格式为:
"_id": "08ff683d86484139",
"_rev": "4-cf6f34c6a2a22780a646b86a3f8d1848",
"lastUpdated": "2014-01-31 00:00:00",
"issueId": 62655,
"isThirdParty": true,
"dateCreated": "2014-01-29 00:00:00",
"attributeCollection": {
"attributeArray": [
{
"updateable": false,
"lookup": "issuetype",
"issueAttributeDefinitionId": 13,
"attributeType": 1,
"name": "Web Type",
"value": [
"Improper Neutralization of Input During Web Page Generation"
]
},
"appReleaseId": 57,
"hash": "953b33eca52938ab2d21e27eb171998b"
}
我的问题是如何以 Json 格式的“attributeCollection”索引属性。特别是,如何索引
"name": "Web Type",
和
"value": ["Improper Neutralization of Input During Web Page Generation"]
【问题讨论】:
-
Nguyen,我认为您尝试解决的用例与过滤名称和/或值有关。我在下面提供了一个解决方案,但它不使用“json”索引。如果下面的答案不能解决您的用例,请告诉我它缺少的地方。谢谢!
标签: json search indexing lucene cloudant