Class DistanceFacetsExample

java.lang.Object
org.apache.lucene.demo.facet.DistanceFacetsExample
All Implemented Interfaces:
Closeable, AutoCloseable

public class DistanceFacetsExample extends Object implements Closeable
Shows simple usage of dynamic range faceting, using the expressions module to calculate distance.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Mean radius of the Earth in KM
    static final double
    The "home" latitude.
    static final double
    The "home" longitude.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Empty constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    org.apache.lucene.search.TopDocs
    drillDown(org.apache.lucene.facet.range.DoubleRange range)
    User drills down on the specified range.
    static org.apache.lucene.search.Query
    getBoundingBoxQuery(double originLat, double originLng, double maxDistanceKM)
    Given a latitude and longitude (in degrees) and the maximum great circle (surface of the earth) distance, returns a simple Filter bounding box to "fast match" candidates.
    void
    Build the example index.
    static void
    main(String[] args)
    Runs the search and drill-down examples and prints the results.
    org.apache.lucene.facet.FacetResult
    User runs a query and counts facets.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • index

      public void index() throws IOException
      Build the example index.
      Throws:
      IOException
    • getBoundingBoxQuery

      public static org.apache.lucene.search.Query getBoundingBoxQuery(double originLat, double originLng, double maxDistanceKM)
      Given a latitude and longitude (in degrees) and the maximum great circle (surface of the earth) distance, returns a simple Filter bounding box to "fast match" candidates.
    • search

      public org.apache.lucene.facet.FacetResult search() throws IOException
      User runs a query and counts facets.
      Throws:
      IOException
    • drillDown

      public org.apache.lucene.search.TopDocs drillDown(org.apache.lucene.facet.range.DoubleRange range) throws IOException
      User drills down on the specified range.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • main

      public static void main(String[] args) throws Exception
      Runs the search and drill-down examples and prints the results.
      Throws:
      Exception