org.apache.lucene.demo.facet
Class DistanceFacetsExample

java.lang.Object
  extended by org.apache.lucene.demo.facet.DistanceFacetsExample
All Implemented Interfaces:
Closeable

public class DistanceFacetsExample
extends Object
implements Closeable

Shows simple usage of dynamic range faceting, using the expressions module to calculate distance.


Field Summary
static double EARTH_RADIUS_KM
          Radius of the Earth in KM NOTE: this is approximate, because the earth is a bit wider at the equator than the poles.
static double ORIGIN_LATITUDE
          The "home" latitude.
static double ORIGIN_LONGITUDE
          The "home" longitude.
 
Constructor Summary
DistanceFacetsExample()
          Empty constructor
 
Method Summary
 void close()
           
 TopDocs drillDown(DoubleRange range)
          User drills down on the specified range.
static Filter getBoundingBoxFilter(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 index()
          Build the example index.
static void main(String[] args)
          Runs the search and drill-down examples and prints the results.
 FacetResult search()
          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 Detail

ORIGIN_LATITUDE

public static final double ORIGIN_LATITUDE
The "home" latitude.

See Also:
Constant Field Values

ORIGIN_LONGITUDE

public static final double ORIGIN_LONGITUDE
The "home" longitude.

See Also:
Constant Field Values

EARTH_RADIUS_KM

public static final double EARTH_RADIUS_KM
Radius of the Earth in KM NOTE: this is approximate, because the earth is a bit wider at the equator than the poles. See http://en.wikipedia.org/wiki/Earth_radius

See Also:
Constant Field Values
Constructor Detail

DistanceFacetsExample

public DistanceFacetsExample()
Empty constructor

Method Detail

index

public void index()
           throws IOException
Build the example index.

Throws:
IOException

getBoundingBoxFilter

public static Filter getBoundingBoxFilter(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 FacetResult search()
                   throws IOException
User runs a query and counts facets.

Throws:
IOException

drillDown

public TopDocs drillDown(DoubleRange range)
                  throws IOException
User drills down on the specified range.

Throws:
IOException

close

public void close()
           throws IOException
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


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.