I am trying to display the results the substring value of one of my properties.
My data has records with a field called serialNumber
, and I have a view like this that returns those records that have "XY" in the field:
function (doc, meta) {
if (doc.serialNumber.indexOf("XY") > -1
&& doc.online
)
{
emit(meta.id, doc.online);
}
}
What I would like to have displayed in the results as well is the third and fourth characters of the serialNumber
. I have tried this:
var prefix = SUBSTR(doc.serialNumber,2,2);
emit(meta.id, doc.online, prefix);
And this:
emit(meta.id, doc.online, doc.serialNumber.substr(2,2);
And also this:
emit(meta.id, doc.online, SUBSTR(doc.serialNumber,2,2));
But the results come back empty.
Thanks.