Class SolrUtil

java.lang.Object
org.opensextant.util.SolrUtil
Direct Known Subclasses:
SolrProxy

public class SolrUtil extends Object
Utility functions better suited in their own class.
Author:
ubaldino
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.opensextant.data.Place
    createPlace(org.apache.solr.common.SolrDocument gazEntry)
    Creates the bare minimum Gazetteer Place record
    static char
    getChar(org.apache.solr.common.SolrDocument solrDoc, String name)
     
    static double[]
    Parse XY pair stored in Solr Spatial4J record.
    static double[]
    getCoordinate(org.apache.solr.common.SolrDocument solrDoc, String field)
    Parse XY pair stored in Solr Spatial4J record.
    static Date
    getDate(org.apache.solr.common.SolrDocument d, String f)
    Get a Date object from a record
    static double
    getDouble(org.apache.solr.common.SolrDocument solrDoc, String name)
    Get a double from a record
    static Float
    getFloat(org.apache.solr.common.SolrDocument d, String f)
    Get a floating point object from a record
    static Float
    getFloat(org.apache.solr.common.SolrInputDocument d, String f)
     
    static int
    getInteger(org.apache.solr.common.SolrDocument d, String f)
    Get an integer from a record
    static int
    getInteger(org.apache.solr.common.SolrInputDocument d, String f)
    get integer value from input document.
    static long
    getLong(org.apache.solr.common.SolrDocument d, String f)
    Get a long from a record
    static String
    getString(org.apache.solr.common.SolrDocument solrDoc, String name)
    Get a String object from a record
    static String
    getString(org.apache.solr.common.SolrInputDocument solrDoc, String name)
    Get a String object from a record on input.
    static List<String>
    getStrings(org.apache.solr.common.SolrDocument d, String f)
     
    static void
    populatePlace(org.apache.solr.common.SolrDocument gazEntry, org.opensextant.data.Place geo)
    Populate the data card.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SolrUtil

      public SolrUtil()
  • Method Details

    • getStrings

      public static List<String> getStrings(org.apache.solr.common.SolrDocument d, String f)
      Parameters:
      d - solr doc
      f - field name
      Returns:
      a list of strings for this field from that document.; Or null if none found.
    • getInteger

      public static int getInteger(org.apache.solr.common.SolrDocument d, String f)
      Get an integer from a record
    • getInteger

      public static int getInteger(org.apache.solr.common.SolrInputDocument d, String f)
      get integer value from input document.
      Parameters:
      d - doc
      f - field name
      Returns:
      int
    • getLong

      public static long getLong(org.apache.solr.common.SolrDocument d, String f)
      Get a long from a record
    • getFloat

      public static Float getFloat(org.apache.solr.common.SolrDocument d, String f)
      Get a floating point object from a record
      Returns:
      NaN if null
    • getFloat

      public static Float getFloat(org.apache.solr.common.SolrInputDocument d, String f)
    • getDate

      public static Date getDate(org.apache.solr.common.SolrDocument d, String f) throws ParseException
      Get a Date object from a record
      Throws:
      ParseException - if DateUtil fails to parse date str
    • getChar

      public static char getChar(org.apache.solr.common.SolrDocument solrDoc, String name)
    • getString

      public static String getString(org.apache.solr.common.SolrInputDocument solrDoc, String name)
      Get a String object from a record on input.
      Parameters:
      solrDoc - solr input document
    • getString

      public static String getString(org.apache.solr.common.SolrDocument solrDoc, String name)
      Get a String object from a record
      Parameters:
      solrDoc - SolrDocument from index
    • getDouble

      public static double getDouble(org.apache.solr.common.SolrDocument solrDoc, String name)
      Get a double from a record
    • getCoordinate

      public static double[] getCoordinate(org.apache.solr.common.SolrDocument solrDoc, String field)
      Parse XY pair stored in Solr Spatial4J record. No validation is done.
      Returns:
      XY double array, [lat, lon]
    • getCoordinate

      public static double[] getCoordinate(String xy)
      Parse XY pair stored in Solr Spatial4J record. No validation is done.
      Returns:
      XY double array, [lat, lon]
    • createPlace

      public static org.opensextant.data.Place createPlace(org.apache.solr.common.SolrDocument gazEntry)
      Creates the bare minimum Gazetteer Place record
      Parameters:
      gazEntry - a solr document of key/value pairs
      Returns:
      Place obj
    • populatePlace

      public static void populatePlace(org.apache.solr.common.SolrDocument gazEntry, org.opensextant.data.Place geo)
      Populate the data card.
      Parameters:
      gazEntry - solr doc
      geo - place obj to populate