elastic-harvester.js
function createCustomRoutingQueryString(pathToCustomRoutingKey, query) {
    const invalidRegexList = [/^ge=/, /^gt=/, /^ge=/, /^lt=/, /\*$/]; // array of invalid regex
    let customRoutingValue;

    if (!pathToCustomRoutingKey) return ''; // customRouting is not enabled for this type
    customRoutingValue = query[pathToCustomRoutingKey]; // fetch the value

    // filters like [ 'gt: '10', lt: '20' ] are not valid customRouting values but may show up
    if (typeof customRoutingValue !== 'string') return '';

    // check for range and wildcard filters
    _.forEach(invalidRegexList, (invalidRegex) => {
      // if our value matches one of these regex, it's probably not the value we should be hashing for customRouting
      if (invalidRegex.test(customRoutingValue)) {
        customRoutingValue = '';
        return false;
      }
      return true;
    });

    return customRoutingValue ? `routing=${customRoutingValue}` : '';
  }
function createCustomRoutingQueryString(pathToCustomRoutingKey, query) {
    const invalidRegexList = [/^ge=/, /^gt=/, /^ge=/, /^lt=/, /\*$/]; // array of invalid regex
    let customRoutingValue;

    if (!pathToCustomRoutingKey) return ''; // customRouting is not enabled for this type
    customRoutingValue = query[pathToCustomRoutingKey]; // fetch the value

    // filters like [ 'gt: '10', lt: '20' ] are not valid customRouting values but may show up
    if (typeof customRoutingValue !== 'string') return '';

    // check for range and wildcard filters
    _.forEach(invalidRegexList, (invalidRegex) => {
      // if our value matches one of these regex, it's probably not the value we should be hashing for customRouting
      if (invalidRegex.test(customRoutingValue)) {
        customRoutingValue = '';
        return false;
      }
      return true;
    });

    return customRoutingValue ? `routing=${customRoutingValue}` : '';
  }
function createCustomRoutingQueryString ( pathToCustomRoutingKey , query ) { const invalidRegexList = [ / ^ge= / , / ^gt= / , / ^ge= / , / ^lt= / , / \*$ / ] ; // array of invalid regex let customRoutingValue ; if ( ! pathToCustomRoutingKey ) return '' ; // customRouting is not enabled for this type customRoutingValue = query [ pathToCustomRoutingKey ] ; // fetch the value // filters like [ 'gt: '10', lt: '20' ] are not valid customRouting values but may show up if ( typeof customRoutingValue !== 'string' ) return '' ; // check for range and wildcard filters _ . forEach ( invalidRegexList , ( invalidRegex ) => { // if our value matches one of these regex, it's probably not the value we should be hashing for customRouting if ( invalidRegex . test ( customRoutingValue ) ) { customRoutingValue = '' ; return false ; } return true ; } ) ; return customRoutingValue ? ` ${ customRoutingValue } ` : '' ; }
Creates a custom routing query string parameter when provided with the pathToCustomRoutingKey and a map of query
string parameters, it will create a custom routing query string parameter, that can be sent to elasticSearch. It
return an empty string if it is unable to create one.

It will validate:
* that custom routing is turned on for this type.
* the value to be used for custom routing is a string
* the string doesn't end with wildcards
* the string doesnt' have operators like ge, gt, le or lt

@param pathToCustomRoutingKey  string, the path to the custom routing key
@param query                   map, of query strings from the request
@returns string                custom routing query string or '' if N/A
Creates a custom routing query string parameter when provided with the pathToCustomRoutingKey and a map of query string parameters it will create a custom routing query string parameter that can be sent to elasticSearch . It return an empty string if it is unable to create one .