Class NumericMetadataFilter

  • All Implemented Interfaces:
    IXMLConfigurable, IDocumentFilter, IOnMatchFilter, IImporterHandler

    public class NumericMetadataFilter
    extends AbstractDocumentFilter

    Accepts or rejects a document based on the numeric value(s) of matching metadata fields, supporting decimals. If multiple values are found for a field, only one of them needs to match for this filter to take effect. If the value is not a valid number, it is considered not to be matching. The decimal character is expected to be a dot. To reject decimals or to deal with non-numeric fields in your own way, you can use TextFilter.

    XML configuration usage:

    
    <handler
        class="com.norconex.importer.handler.filter.impl.NumericMetadataFilter"
        onMatch="[include|exclude]">
      <!-- multiple "restrictTo" tags allowed (only one needs to match) -->
      <restrictTo>
        <fieldMatcher>(field-matching expression)</fieldMatcher>
        <valueMatcher>(value-matching expression)</valueMatcher>
      </restrictTo>
      <fieldMatcher>(expression matching numeric fields to filter)</fieldMatcher>
      <!--
        Use one or two (for ranges) conditions,
                where possible operators are:
    
                  gt -> greater than
                  ge -> greater equal
                  lt -> lower than
                  le -> lowe equal
                  eq -> equals
        -->
      <condition
          operator="[gt|ge|lt|le|eq]"
          number="(number)"/>
    </handler>

    XML usage example:

    
    <handler
        class="NumericMetadataFilter"
        onMatch="include">
      <fieldMatcher>age</fieldMatcher>
      <condition
          operator="ge"
          number="20"/>
      <condition
          operator="lt"
          number="30"/>
    </handler>

    Let's say you are importing customer profile documents and you have a field called "age" and you need to only consider documents for customers in their twenties (greater or equal to 20, but lower than 30). The above example would achieve that.

    Since:
    2.2.0
    Author:
    Pascal Essiembre