def fieldHistogram(
        self, name, q="*:*", fq=None, nbins=10, minmax=None, includequeries=True
    ):
        """Generates a histogram of values. Expects the field to be integer or floating
        point.

        @param name(string) Name of the field to compute
        @param q(string) The query identifying the set of records for the histogram
        @param fq(string) Filter query to restrict application of query
        @param nbins(int) Number of bins in resulting histogram

        @return list of [binmin, binmax, n, binquery]

        """
        oldpersist = self.persistent
        self.persistent = True
        ftype = self.getftype(name)
        if ftype == str:
            ##handle text histograms over here
            bins = self.fieldAlphaHistogram(
                name, q=q, fq=fq, nbins=nbins, includequeries=includequeries
            )
            self.persistent = oldpersist
            if not self.persistent:
                self.conn.close()
            return bins
        bins = []
        qbin = []
        fvals = self.fieldValues(name, q, fq, maxvalues=nbins + 1)
        if len(fvals[name]) < 3:
            return bins
        nvalues = len(fvals[name]) / 2
        if nvalues < nbins:
            nbins = nvalues
        minoffset = 1
        if ftype == float:
            minoffset = 0.00001
        try:
            if minmax is None:
                minmax = self.fieldMinMax(name, q=q, fq=fq)
                # logging.info("MINMAX = %s" % str(minmax))
                minmax[0] = float(minmax[0])
                minmax[1] = float(minmax[1])
            delta = (minmax[1] - minmax[0]) / nbins
            for i in range(0, nbins):
                binmin = minmax[0] + (i * delta)
                bin = [binmin, binmin + delta, 0]
                if ftype == int:
                    bin[0] = int(bin[0])
                    bin[1] = int(bin[1])
                    if i == 0:
                        binq = '%s:[* TO %d]' % (name, bin[1])
                    elif i == nbins - 1:
                        binq = '%s:[%d TO *]' % (name, bin[0] + minoffset)
                        bin[0] = bin[0] + minoffset
                        if bin[1] < bin[0]:
                            bin[1] = bin[0]
                    else:
                        binq = '%s:[%d TO %d]' % (name, bin[0] + minoffset, bin[1])
                        bin[0] = bin[0] + minoffset
                else:
                    if i == 0:
                        binq = '%s:[* TO %f]' % (name, bin[1])
                    elif i == nbins - 1:
                        binq = '%s:[%f TO *]' % (name, bin[0] + minoffset)
                    else:
                        binq = '%s:[%f TO %f]' % (name, bin[0] + minoffset, bin[1])
                qbin.append(binq)
                bins.append(bin)

            # now execute the facet query request
            params = {
                'q': q,
                'rows': '0',
                'facet': 'true',
                'facet.field': name,
                'facet.limit': '1',
                'facet.mincount': 1,
                'wt': 'python',
            }
            request = urllib.parse.urlencode(params, doseq=True)
            for sq in qbin:
                request = request + '&%s' % urllib.parse.urlencode({'facet.query': sq})
            rsp = self.doPost(self.solrBase + '', request, self.formheaders)
            data = eval(rsp.read())
            for i in range(0, len(bins)):
                v = data['facet_counts']['facet_queries'][qbin[i]]
                bins[i][2] = v
                if includequeries:
                    bins[i].append(qbin[i])
        finally:
            self.persistent = oldpersist
            if not self.persistent:
                self.conn.close()
        return bins