/**
  * 设置BigDecimal对象
  *
  * @param name 名称
  * @param value 值
  * @param document document
  * @param luceneOptions luceneOptions
  */
 @Override
 public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
   if (value != null) {
     BigDecimal decimalValue = (BigDecimal) value;
     luceneOptions.addNumericFieldToDocument(name, decimalValue.doubleValue(), document);
   }
 }
  @Override
  public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value == null) {
      return;
    }

    Date date = (Date) value;
    long numericDate = DateTools.round(date.getTime(), resolution);
    luceneOptions.addNumericFieldToDocument(name, numericDate, document);
  }
  @Override
  public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    Date date = (Date) value;
    Calendar cal = GregorianCalendar.getInstance(GMT);
    cal.setTime(date);
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);

    // set year
    luceneOptions.addFieldToDocument(name + ".year", String.valueOf(year), document);

    // set month and pad it if needed
    luceneOptions.addFieldToDocument(
        name + ".month", month < 10 ? "0" : "" + String.valueOf(month), document);

    // set day and pad it if needed
    luceneOptions.addFieldToDocument(
        name + ".day", day < 10 ? "0" : "" + String.valueOf(day), document);
  }
  /**
   * Actual overridden method that does the indexing
   *
   * @param name of the field
   * @param value of the field
   * @param document document being indexed
   * @param luceneOptions current indexing options and accessors
   */
  @Override
  public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value != null) {

      Double latitude = getLatitude(value);
      Double longitude = getLongitude(value);

      if ((latitude != null) && (longitude != null)) {

        if (spatialHashIndex) {
          Point point = Point.fromDegrees(latitude, longitude);

          for (int i = topSpatialHashLevel; i <= bottomSpatialHashLevel; i++) {
            luceneOptions.addFieldToDocument(
                SpatialHelper.formatFieldName(i, name),
                SpatialHelper.getSpatialHashCellId(point, i),
                document);
          }
        }

        if (numericFieldsIndex) {
          final String latitudeFieldName = SpatialHelper.formatLatitude(name);
          final String longitudeFieldName = SpatialHelper.formatLongitude(name);
          luceneOptions.addNumericFieldToDocument(latitudeFieldName, latitude, document);

          luceneOptions.addNumericFieldToDocument(longitudeFieldName, longitude, document);

          Field latitudeDocValuesField =
              new SpatialNumericDocValueField(latitudeFieldName, latitude);
          document.add(latitudeDocValuesField);

          Field longitudeDocValuesField =
              new SpatialNumericDocValueField(longitudeFieldName, longitude);
          document.add(longitudeDocValuesField);
        }
      }
    }
  }
  @Override
  public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    GolfPlayer player = (GolfPlayer) value;

    StringBuilder names = new StringBuilder();
    if (player.getFirstName() != null) {
      names.append(player.getFirstName()).append(" ");
    }
    if (player.getLastName() != null) {
      names.append(player.getLastName());
    }

    luceneOptions.addFieldToDocument(name, names.toString(), document);
  }
Exemple #6
0
  @Override
  public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    // In this particular class the name of the new field was passed
    // from the name field of the ClassBridge Annotation. This is not
    // a requirement. It just works that way in this instance. The
    // actual name could be supplied by hard coding it below.
    Departments deps = (Departments) value;
    String fieldValue1 = deps.getManufacturer();

    if (fieldValue1 != null) {
      String indexedString = equips.get(fieldValue1);
      luceneOptions.addFieldToDocument(name, indexedString, document);
    }
  }
    @Override
    public void set(
        String name,
        Object value,
        Document document,
        LuceneOptions luceneOptions,
        Metadata metadata) {
      invocationCount++;

      assertEquals(
          "Metadata.RESOURCE_NAME_KEY should be set in the metadata",
          PATH_TO_TEST_DOCUMENT_PDF,
          metadata.get(Metadata.RESOURCE_NAME_KEY));

      // indexing the discovered content type
      luceneOptions.addFieldToDocument("type", metadata.get(Metadata.CONTENT_TYPE), document);
    }
 @Override
 public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
   if (value != null) {
     luceneOptions.addNumericFieldToDocument(name, value, document);
   }
 }