Reputation: 3
I have a json document example:
{
"_id": "1000001101012017",
"_rev": "1-b7de1e91dbcac1ca098be7d99ddea138",
"ACC_ID": 1005,
"DT": 201701010000000000,
"DBO": 0.9,
"CRO": 0,
"SALDO": -2.05
}
and the Search index function:
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})
}
}
search query is:
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1
}
and response:
{
"total_rows": 4,
"bookmark": "g1AAAABReJzLYWBgYMxgTmGQS87JL01JzCtxKCkugbFTkoz1Mgr1SpKSc4DqmPJYGFYBAZD6DwRZYDE357aU7W4tTgpJDKvUqrKyACwGG7U",
"rows": [
{
"id": "100502012017",
"order": [
201702010000000000,
11150970
],
"fields": {
"DT": 201702010000000000,
"ACC_ID": 1005
}
}
]
}
response is without "SALDO" field but when
"q":"ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215] AND SALDO: [-identity TO identity]"
response is result with "SALDO" but waithing ~10 second.
How can I get a response with "SALDO" and be high performanse?
Upvotes: 0
Views: 98
Reputation: 5637
One way to solve you problem is to use add include_docs=true
to your query string i.e.
{
"q": "ACC_ID: 1005 AND DT: [198905260000000000 TO 201702241046285215]",
"sort": "-DT",
"limit": 1,
"include_docs": true
}
The search results will then contain the entire document in the result object.
Upvotes: 1