Package org.apache.nutch.indexer.geoip

# Class GeoIPDocumentCreator

java.lang.Object
org.apache.nutch.indexer.geoip.GeoIPDocumentCreator

public class GeoIPDocumentCreator extends Object

Simple utility class which builds a `NutchDocument` based on input from `GeoIPIndexingFilter`, where configuration is also read.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static NutchDocument`
  `createDocFromAnonymousIpDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in Anonymous IP database.
  `static NutchDocument`
  `createDocFromAsnDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in ASN database.
  `static NutchDocument`
  `createDocFromCityDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in City database.
  `static NutchDocument`
  `createDocFromConnectionDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in ConnectionDb.
  `static NutchDocument`
  `createDocFromCountryDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in Country database.
  `static NutchDocument`
  `createDocFromDomainDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in Domain database.
  `static NutchDocument`
  `createDocFromInsightsService(String serverIp, NutchDocument doc, com.maxmind.geoip2.WebServiceClient client)`
  Populate a `NutchDocument` based on lookup of IP using the MaxMind Insights web service.
  `static NutchDocument`
  `createDocFromIspDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader)`
  Populate a `NutchDocument` based on lookup of IP in ISP database.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### createDocFromAnonymousIpDb

    public static NutchDocument createDocFromAnonymousIpDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in Anonymous IP database.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromAsnDb

    public static NutchDocument createDocFromAsnDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in ASN database.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromCityDb

    public static NutchDocument createDocFromCityDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in City database.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromConnectionDb

    public static NutchDocument createDocFromConnectionDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in ConnectionDb.
    Parameters:
      `serverIp` - the server IP
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromCountryDb

    public static NutchDocument createDocFromCountryDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in Country database. This is a lighter-weight alternative to the City database when only country-level information is needed.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromDomainDb

    public static NutchDocument createDocFromDomainDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in Domain database.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromInsightsService

    public static NutchDocument createDocFromInsightsService(String serverIp, NutchDocument doc, com.maxmind.geoip2.WebServiceClient client) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP using the MaxMind Insights web service.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `client` - WebServiceClient for MaxMind Insights API
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception

  - ### createDocFromIspDb

    public static NutchDocument createDocFromIspDb(String serverIp, NutchDocument doc, com.maxmind.geoip2.DatabaseReader reader) throws IOException, com.maxmind.geoip2.exception.GeoIp2Exception
    Populate a `NutchDocument` based on lookup of IP in ISP database.
    Parameters:
      `serverIp` - the server IP address to lookup
      `doc` - NutchDocument to populate
      `reader` - instantiated DatabaseReader object
    Returns:
      populated NutchDocument
    Throws:
      `IOException` - if an error occurs performing the Db lookup
      `com.maxmind.geoip2.exception.GeoIp2Exception` - generic GeoIp2 exception