docs: def field_alpha_histogram(
          self, name, n_bins=10, include_queries=True, **query_dict
      ):
          """Generates a histogram of values from a string field.
  
          Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal
          division of the fields.
  
          """
          bin_list = []
          q_bin = []
          try:
              # get total number of values for the field
              # TODO: this is a slow mechanism to retrieve the number of distinct values
              # Need to replace this with something more efficient.
              # Can probably replace with a range of alpha chars - need to check on
              # case sensitivity
              param_dict = query_dict.copy()
              f_vals = self.get_field_values(name, maxvalues=-1, **param_dict)
              n_values = len(f_vals[name]) // 2
              if n_values < n_bins:
                  n_bins = n_values
              if n_values == n_bins:
                  # Use equivalence instead of range queries to retrieve the
                  # values
                  for i in range(n_bins):
                      a_bin = [f_vals[name][i * 2], f_vals[name][i * 2], 0]
                      bin_q = '{}:{}'.format(
                          name, self._prepare_query_term(name, a_bin[0])
                      )
                      q_bin.append(bin_q)
                      bin_list.append(a_bin)
              else:
                  delta = n_values / n_bins
                  if delta == 1:
                      # Use equivalence queries, except the last one which includes the
                      # remainder of terms
                      for i in range(n_bins - 1):
                          a_bin = [f_vals[name][i * 2], f_vals[name][i * 2], 0]
                          bin_q = '{}:{}'.format(
                              name, self._prepare_query_term(name, a_bin[0])
                          )
                          q_bin.append(bin_q)
                          bin_list.append(a_bin)
                      term = f_vals[name][(n_bins - 1) * 2]
                      a_bin = [term, f_vals[name][((n_values - 1) * 2)], 0]
                      bin_q = '{}:[{} TO *]'.format(
                          name, self._prepare_query_term(name, term)
                      )
                      q_bin.append(bin_q)
                      bin_list.append(a_bin)
                  else:
                      # Use range for all terms
                      # now need to page through all the values and get those at
                      # the edges
                      c_offset = 0.0
                      delta = float(n_values) / float(n_bins)
                      for i in range(n_bins):
                          idx_l = int(c_offset) * 2
                          idx_u = (int(c_offset + delta) * 2) - 2
                          a_bin = [f_vals[name][idx_l], f_vals[name][idx_u], 0]
                          # logger.info(str(a_bin))
                          try:
                              if i == 0:
                                  bin_q = '{}:[* TO {}]'.format(
                                      name, self._prepare_query_term(name, a_bin[1])
                                  )
                              elif i == n_bins - 1:
                                  bin_q = '{}:[{} TO *]'.format(
                                      name, self._prepare_query_term(name, a_bin[0])
                                  )
                              else:
                                  bin_q = '{}:[{} TO {}]'.format(
                                      name,
                                      self._prepare_query_term(name, a_bin[0]),
                                      self._prepare_query_term(name, a_bin[1]),
                                  )
                          except Exception:
                              self._log.exception('Exception:')
                              raise
                          q_bin.append(bin_q)
                          bin_list.append(a_bin)
                          c_offset = c_offset + delta
              # now execute the facet query request
              param_dict = query_dict.copy()
              param_dict.update(
                  {
                      'rows': '0',
                      'facet': 'true',
                      'facet.field': name,
                      'facet.limit': '1',
                      'facet.mincount': 1,
                      'facet.query': [sq.encode('utf-8') for sq in q_bin],
                  }
              )
              resp_dict = self._post_query(**param_dict)
              for i in range(len(bin_list)):
                  v = resp_dict['facet_counts']['facet_queries'][q_bin[i]]
                  bin_list[i][2] = v
                  if include_queries:
                      bin_list[i].append(q_bin[i])
          except Exception:
              self._log.exception('Exception')
              raise
          return bin_list