code: function findMatchingIndexes(selector, userFields, sortOrder, indexes) {
  
    return indexes.reduce(function (res, index) {
      var indexMatches = checkIndexMatches(index, sortOrder, userFields, selector);
      if (indexMatches) {
        res.push(index);
      }
      return res;
    }, []);
  }
docs: the algorithm is very simple: take all the fields the user supplies, and if those fields are a strict subset of the fields in some index, then use that index