コード例 #1
0
  @Override
  protected void doCollect(int doc) throws IOException {
    if (!latFieldData.hasValue(doc) || !lonFieldData.hasValue(doc)) {
      return;
    }

    double value = ((Number) valueFunction.execute(doc, params)).doubleValue();

    if (latFieldData.multiValued()) {
      double[] lats = latFieldData.doubleValues(doc);
      double[] lons = latFieldData.doubleValues(doc);
      for (int i = 0; i < lats.length; i++) {
        double distance = geoDistance.calculate(lat, lon, lats[i], lons[i], unit);
        for (GeoDistanceFacet.Entry entry : entries) {
          if (distance >= entry.getFrom() && distance < entry.getTo()) {
            entry.count++;
            entry.total += value;
          }
        }
      }
    } else {
      double distance =
          geoDistance.calculate(
              lat, lon, latFieldData.doubleValue(doc), lonFieldData.doubleValue(doc), unit);
      for (GeoDistanceFacet.Entry entry : entries) {
        if (distance >= entry.getFrom() && distance < entry.getTo()) {
          entry.count++;
          entry.total += value;
        }
      }
    }
  }
コード例 #2
0
 @Override
 protected void doSetNextReader(IndexReader reader, int docBase) throws IOException {
   super.doSetNextReader(reader, docBase);
   valueFunction.setNextReader(reader);
 }