1

I'm trying to limit the map in my view to a specific set of documents by either having the id "startsWith" a string or based on there being a specific node in the JSON> I can't seem to get a result set once I add an IF statement. The reduce is a simple _count:

function(doc, meta) {
  if (doc.metricType == "Limit_Exceeded") {
    emit([doc.ownedByCustomerNumber, doc.componentProduct.category], meta.id);
  }
}

I've also tried if (doc.metricType) and also if(meta.id.startsWith("Turnaway:")

Example Doc:

{
      "OvidUserId": 26105400,
      "id": "Turnaway:00005792:10562440",
      "ipAddress": "111187081038",
      "journalTurnawayNumber": 10562440,
      "metricType": "Limit_Exceeded",
      "oaCode": "OA_Gold",
      "orderNumber": 683980,
      "ovidGroupID": 3113900,
      "ovidGroupName": "tnu999",
      "ovidUserName": "tnu999",
      "ownedByCustomerNumber": 59310,
      "platform": "Lippincott",
      "samlString": "",
      "serialName": "00005792",
      "sessionID": "857616ee-dab7-43d0-a08b-abb2482297dd",
      "soldProduct": {
        "category": "Multidisciplinary Subjects",
        "name": "Custom Collection For CALIS - LWW TA 2020",
        "productCode": "CCFCCSI20",
        "productNumber": 33410,
        "subCategory": "",
        "subject": "Multidisciplinary Subjects"
      },
      "soldToCustomer": {
        "customerNumber": 59310,
        "keyAccount": false,
        "name": "Tongji University"
      },
      "turnawayDateTime": "2022-05-04T03:01:44.600",
      "usedByCustomer": {
        "customerNumber": 59310,
        "keyAccount": false,
        "name": "Tongji University"
      },
      "usedByCustomerNumber": 59310,
      "yearMonth": "202205"
    },
    "id": "Turnaway:00005792:10562440"
  }

Thanks, Gerry

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121

1 Answers1

1

Found it (of course after posting the question) The second component of the Key in the emit has to exist. I entered doc.componentProduct.category instead of doc.soldProduct.Category.