没有一个索引字段的 Cloudant 搜索索引响应
Cloudant search index response without one index field
我有一个 json 文档示例:
{
"_id": "1000001101012017",
"_rev": "1-b7de1e91dbcac1ca098be7d99ddea138",
"ACC_ID": 1005,
"DT": 201701010000000000,
"DBO": 0.9,
"CRO": 0,
"SALDO": -2.05
}
和搜索索引功能:
function (doc) {
index("saldoSearch", doc._id);
if(doc.DT){
index("DT", doc.DT, {"store":true})
}
if(doc.ACC_ID){
index("ACC_ID", doc.ACC_ID, {"store":true})
}
if(doc.SALDO){
index("SALDO", doc.SALDO, {"store":true})
}
}
搜索查询是:
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1
}
和响应:
{
"total_rows": 4,
"bookmark": "g1AAAABReJzLYWBgYMxgTmGQS87JL01JzCtxKCkugbFTkoz1Mgr1SpKSc4DqmPJYGFYBAZD6DwRZYDE357aU7W4tTgpJDKvUqrKyACwGG7U",
"rows": [
{
"id": "100502012017",
"order": [
201702010000000000,
11150970
],
"fields": {
"DT": 201702010000000000,
"ACC_ID": 1005
}
}
]
}
响应没有 "SALDO" 字段,但是当
"q":"ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215] AND SALDO: [-identity TO identity]"
响应是 "SALDO" 的结果,但等待 ~10 秒。
如何获得 "SALDO" 的响应并保持高效?
解决您问题的一种方法是使用添加 include_docs=true
到您的查询字符串,即
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1,
"include_docs": true
}
搜索结果将在结果对象中包含整个文档。
我有一个 json 文档示例:
{
"_id": "1000001101012017",
"_rev": "1-b7de1e91dbcac1ca098be7d99ddea138",
"ACC_ID": 1005,
"DT": 201701010000000000,
"DBO": 0.9,
"CRO": 0,
"SALDO": -2.05
}
和搜索索引功能:
function (doc) {
index("saldoSearch", doc._id);
if(doc.DT){
index("DT", doc.DT, {"store":true})
}
if(doc.ACC_ID){
index("ACC_ID", doc.ACC_ID, {"store":true})
}
if(doc.SALDO){
index("SALDO", doc.SALDO, {"store":true})
}
}
搜索查询是:
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1
}
和响应:
{
"total_rows": 4,
"bookmark": "g1AAAABReJzLYWBgYMxgTmGQS87JL01JzCtxKCkugbFTkoz1Mgr1SpKSc4DqmPJYGFYBAZD6DwRZYDE357aU7W4tTgpJDKvUqrKyACwGG7U",
"rows": [
{
"id": "100502012017",
"order": [
201702010000000000,
11150970
],
"fields": {
"DT": 201702010000000000,
"ACC_ID": 1005
}
}
]
}
响应没有 "SALDO" 字段,但是当
"q":"ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215] AND SALDO: [-identity TO identity]"
响应是 "SALDO" 的结果,但等待 ~10 秒。
如何获得 "SALDO" 的响应并保持高效?
解决您问题的一种方法是使用添加 include_docs=true
到您的查询字符串,即
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1,
"include_docs": true
}
搜索结果将在结果对象中包含整个文档。