docs: def _map_term_using_schema(master, path, term, schema_edges):
      """
      IF THE WHERE CLAUSE REFERS TO FIELDS IN THE SCHEMA, THEN EXPAND THEM
      """
      output = FlatList()
      for k, v in term.items():
          dimension = schema_edges[k]
          if isinstance(dimension, Dimension):
              domain = dimension.getDomain()
              if dimension.fields:
                  if is_data(dimension.fields):
                      # EXPECTING A TUPLE
                      for local_field, es_field in dimension.fields.items():
                          local_value = v[local_field]
                          if local_value == None:
                              output.append({"missing": {"field": es_field}})
                          else:
                              output.append({"term": {es_field: local_value}})
                      continue
  
                  if len(dimension.fields) == 1 and is_variable_name(dimension.fields[0]):
                      # SIMPLE SINGLE-VALUED FIELD
                      if domain.getPartByKey(v) is domain.NULL:
                          output.append({"missing": {"field": dimension.fields[0]}})
                      else:
                          output.append({"term": {dimension.fields[0]: v}})
                      continue
  
                  if AND(is_variable_name(f) for f in dimension.fields):
                      # EXPECTING A TUPLE
                      if not isinstance(v, tuple):
                          Log.error("expecing {{name}}={{value}} to be a tuple",  name= k,  value= v)
                      for i, f in enumerate(dimension.fields):
                          vv = v[i]
                          if vv == None:
                              output.append({"missing": {"field": f}})
                          else:
                              output.append({"term": {f: vv}})
                      continue
              if len(dimension.fields) == 1 and is_variable_name(dimension.fields[0]):
                  if domain.getPartByKey(v) is domain.NULL:
                      output.append({"missing": {"field": dimension.fields[0]}})
                  else:
                      output.append({"term": {dimension.fields[0]: v}})
                  continue
              if domain.partitions:
                  part = domain.getPartByKey(v)
                  if part is domain.NULL or not part.esfilter:
                      Log.error("not expected to get NULL")
                  output.append(part.esfilter)
                  continue
              else:
                  Log.error("not expected")
          elif is_data(v):
              sub = _map_term_using_schema(master, path + [k], v, schema_edges[k])
              output.append(sub)
              continue
  
          output.append({"term": {k: v}})
      return {"and": output}