没有一个索引字段的Cloudant搜索索引响应

时间:2017-09-13 07:28:05

标签: search indexing lucene cloudant

我有一个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"并且是高绩效的?

1 个答案:

答案 0 :(得分:1)

解决问题的一种方法是在查询字符串中添加include_docs=true,即

{
  "q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
  "sort": "-DT",
  "limit": 1,
  "include_docs": true
}

搜索结果将在结果对象中包含整个文档。