How can I index nested object using couchdb-lucene

418 Views Asked by At

Index function

When I try to index sub-property of doc in indexing function, like ret.add(doc.complaint.status, {field: 'status', type: 'string'}) couchdb-lucene returns 500.

function (doc) {
  var ret = new Document();

  ret.add(doc.customerName, {
    type: 'string',
    field: 'customerName'
  });

  ret.add(doc.complaint.status, {
    type: 'string',
    field: 'status'
  });

  ret.add(doc.complaint.numberOfCoupons, {
    type: 'int',
    field: 'numberOfCoupons'
  });

  return ret;
}

Object which exists in couchdb

{ "customerName": "Roman Maltsev", "complaint": { "status": "In progress", "numberOfCoupons": 10 } }

Query using proxy GET http://localhost:5984/_fti/local/complaints-management-rom/_design/find/all?q=status:"In progress" returns 500

1

There are 1 best solutions below

0
On BEST ANSWER

Actually the problem was that lucene index each document, including _design/view itself, so I need just check does property exists or not