Package com.attivio.sdk.search.query
Class GeoDistanceQuery
- java.lang.Object
-
- com.attivio.sdk.search.query.Query
-
- com.attivio.sdk.search.query.GeoDistanceQuery
-
- All Implemented Interfaces:
QueryParameters
,LocaleAware
,java.io.Serializable
,java.lang.Cloneable
public final class GeoDistanceQuery extends Query
Query for matching documents that are a desired distance from a center point.NOTE: Distances are treated in kilometers by default. Latitude and Longitude are specified in degrees. Use
setDistanceUnits(DistanceUnits)
to change the units used for the distance.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.attivio.sdk.search.query.QueryParameters
QueryParameters.Parameter
-
-
Field Summary
Fields Modifier and Type Field Description static DistanceUnits
DEFAULT_DISTANCE_UNITS
Default units for distance measurements.protected QueryParameters.Parameter
parameters
-
Fields inherited from class com.attivio.sdk.search.query.Query
boost, DEFAULT_PARAMETERS, IGNORE_PARAMETERS
-
Fields inherited from interface com.attivio.sdk.search.query.QueryParameters
ACL, ACRONYMS, ACRONYMS_EXPANDED, ACRONYMS_ORIGINAL, ALIAS, ALLOW, ANONYMOUS, BOOST, BOOST_FREQUENCY, BOOST_POSITION, BOOST_PROXIMITY, COMPLETENESS_BOOST, DEFAULT_BOOST, DEFAULT_DEPTH, DEFAULT_FIELD_NORMS, DEFAULT_FUZZY_MAX_TERMS, DEFAULT_MINIMUM, DEFAULT_QUOTED, DEFAULT_RECURSIVE, DEFAULT_ROLLUP_LIMIT, DEFAULT_SCORE_DEPTH, DEFAULT_SCORE_EXPLAIN, DEFAULT_SEARCH_FIELD, DEFAULT_SIMILARITY, DEFAULT_SPAN, DENY, DEPTH, DISABLE_COORD, DISTANCE, FACET, FIELD_NORMS, FUZZY_MAX_TERMS, INDEX, LANGUAGE, LOWER, METHOD, MINIMUM, ON, ORDER, QUERY, QUERY_LANGUAGE, QUOTED, RECURSIVE, RELEVANCY_MODEL, ROLLUP, SCORE_DEPTH, SCORE_EXPLAIN, SCORE_FUNCTIONS, SCORE_MODE, SIMILARITY, SIMILARITY_PREFIX, SOUNDS_LIKE, SPAN, SPELLCHECK_CORRECTED, SPELLCHECK_EXPANDED, SPELLCHECK_MODE, SPELLCHECK_ORIGINAL, SPELLCHECK_SUGGESTIONS, STOPWORDS, SYNONYMS, SYNONYMS_EXPANDED, SYNONYMS_ORIGINAL, TOKENIZE, UNSECURED_ZONES, UPPER, WARNING, WILDCARD, XON
-
-
Constructor Summary
Constructors Constructor Description GeoDistanceQuery()
ConstructorGeoDistanceQuery(double distance)
GeoDistanceQuery(double distance, DistanceUnits units)
GeoDistanceQuery(java.lang.String field, Point center, double distance)
GeoDistanceQuery(java.lang.String field, Point center, double distance, DistanceUnits distanceUnits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
addParameter(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add "\"name
\"=\"value
\"" tobuffer
.protected static void
addParameterCompact(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add "\"name
\"=\"value
\"" tobuffer
, omitting value if it is Boolean.TRUE.protected static void
appendParameter(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add ", \"name
\"=\"value
\"" tobuffer
.GeoDistanceQuery
clone()
Returns a deep copy of this Query instance.boolean
containsParameter(java.lang.String name)
Returns true if the specified parameter exists for this Query object.protected boolean
equals(java.lang.Object other, java.util.Map<java.lang.String,java.lang.Object> defaults, java.util.Set<java.lang.String> ignore)
Checks whetherquery
equals this Query object.protected static void
escape(java.lang.StringBuilder buffer, java.lang.Object value)
protected void
escape(java.lang.StringBuilder buffer, java.lang.String value, boolean quote)
Helper method to escape a string for toString() .Point
getCenter()
Get the center point to calculate distance from.double
getDistance()
Get the maximum distance from the center a document must have to match.DistanceUnits
getDistanceUnits()
Get the units that minDistance and maxDistance are specified injava.lang.String
getField()
Get the field to query.java.lang.Object
getParameter(java.lang.String name)
Returns a named property for this Query object.boolean
getParameter(java.lang.String name, boolean defaultValue)
Gets a boolean parameter.double
getParameter(java.lang.String name, double defaultValue)
Gets a double parameter.float
getParameter(java.lang.String name, float defaultValue)
Gets a float parameter.int
getParameter(java.lang.String name, int defaultValue)
Gets an integer parameter.long
getParameter(java.lang.String name, long defaultValue)
Gets a long parameter.java.lang.Object
getParameter(java.lang.String name, java.lang.Object defaultValue)
Gets a parameter.java.lang.String
getParameter(java.lang.String name, java.lang.String defaultValue)
Gets a String parameter.java.util.List<java.lang.Object>
getParameterList(java.lang.String name)
Returns list of values found for the named property for this Query object.int
hashCode()
protected static java.lang.StringBuilder
indent(java.lang.StringBuilder buffer, int indent)
Support method to indent a "line" in a StringBuilder.java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>>
parameters()
Get an iterator for returning all custom parameters.protected static int
parseIntParameter(java.lang.Object value, int defaultValue)
java.lang.String
prettyFormat()
Returns a hierarchical representation of this query as a string.protected void
prettyFormat(java.lang.StringBuilder buffer, int indent)
Pretty format all parameters for this Query instance.void
prettyPrint()
Sends a hierarchical representation of this query to standard out.void
prettyPrint(java.io.PrintStream out)
Sends a hierarchical representation of this query specified PrintStream.java.lang.Object
removeParameter(java.lang.String name)
Remove the value for a parameter for this Query object.protected void
setBooleanParameter(java.lang.String key, java.lang.Object value)
Internal method for setting a boolean parameter.void
setCenter(Point value)
Set the center point to calculate distance from.void
setDistance(double value)
Set the maximum distance from the center a document must have to match.void
setDistanceUnits(DistanceUnits units)
Set the units that minDistance and maxDistance are specified inprotected void
setEnumParameter(java.lang.String key, java.lang.Object value, java.lang.String... enumValues)
Internal method for setting an object parameter.void
setField(java.lang.String value)
Set the field to query.protected void
setIntegerParameter(java.lang.String key, java.lang.Object value)
Internal method for setting an integer parameter.void
setParameter(java.lang.String key, java.lang.Object value)
void
setParameters(java.util.Map<java.lang.String,java.lang.Object> value)
void
setParameters(java.util.Map<java.lang.String,java.lang.Object> params, boolean override)
Copies parameters from a Map into this Query.protected void
setRollupParameter(java.lang.String key, java.lang.Object value)
protected void
setStringParameter(java.lang.String key, java.lang.Object value)
Internal method for setting a string parameter.protected void
setUnsignedParameter(java.lang.String key, java.lang.Object value)
Internal method for setting an integer parameter.java.lang.String
toString()
java.lang.String
toString(boolean compact)
protected void
toString(java.lang.StringBuilder buffer, boolean compact)
Write the String representation of this query tobuffer
.-
Methods inherited from class com.attivio.sdk.search.query.Query
addParameter, addParameters, appendParameters, containsParameters, equals, equals, equals, getAllParameters, getBoost, getFirstNode, getInternalParameter, getLocale, getNodes, getNodes, getQueryLanguage, getQueryString, isCompactParameter, optimize, prettyFormatParameters, rewrite, rewriteChildren, setBoost, setBoost, setLocale, setParameters, setParameters, toCompactString, valueOf
-
-
-
-
Field Detail
-
DEFAULT_DISTANCE_UNITS
public static final DistanceUnits DEFAULT_DISTANCE_UNITS
Default units for distance measurements.
-
parameters
protected QueryParameters.Parameter parameters
-
-
Constructor Detail
-
GeoDistanceQuery
public GeoDistanceQuery()
Constructor
-
GeoDistanceQuery
public GeoDistanceQuery(double distance)
-
GeoDistanceQuery
public GeoDistanceQuery(double distance, DistanceUnits units)
-
GeoDistanceQuery
public GeoDistanceQuery(java.lang.String field, Point center, double distance)
-
GeoDistanceQuery
public GeoDistanceQuery(java.lang.String field, Point center, double distance, DistanceUnits distanceUnits)
-
-
Method Detail
-
setParameter
public void setParameter(java.lang.String key, java.lang.Object value)
- Overrides:
setParameter
in classQuery
-
getField
public java.lang.String getField()
Get the field to query.If
null
, the default geo location field for the query will be used. This isFieldNames.POSITION
by default.
-
setField
public void setField(java.lang.String value)
Set the field to query.
-
getCenter
public Point getCenter()
Get the center point to calculate distance from.If
null
, the default geo location center point for theQueryRequest
will be used. IfQueryRequest
does not have a geo location set, the query will fail.
-
setCenter
public void setCenter(Point value)
Set the center point to calculate distance from.
-
getDistance
public double getDistance()
Get the maximum distance from the center a document must have to match.
-
setDistance
public void setDistance(double value)
Set the maximum distance from the center a document must have to match.
-
getDistanceUnits
public DistanceUnits getDistanceUnits()
Get the units that minDistance and maxDistance are specified in
-
setDistanceUnits
public void setDistanceUnits(DistanceUnits units)
Set the units that minDistance and maxDistance are specified in
-
toString
protected void toString(java.lang.StringBuilder buffer, boolean compact)
Write the String representation of this query tobuffer
.
-
prettyFormat
protected void prettyFormat(java.lang.StringBuilder buffer, int indent)
Pretty format all parameters for this Query instance.- Parameters:
buffer
- buffer to write pretty formated parameters to.indent
- the indentation level
-
hashCode
public int hashCode()
-
equals
protected boolean equals(java.lang.Object other, java.util.Map<java.lang.String,java.lang.Object> defaults, java.util.Set<java.lang.String> ignore)
Checks whetherquery
equals this Query object.
-
clone
public GeoDistanceQuery clone()
Returns a deep copy of this Query instance.NOTE: values for parameters are shallow copied.
-
parameters
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>> parameters()
Get an iterator for returning all custom parameters.
-
containsParameter
public boolean containsParameter(java.lang.String name)
Returns true if the specified parameter exists for this Query object.- Parameters:
name
- parameter name.- Returns:
- true if the specified parameter exists.
-
getParameter
public final java.lang.Object getParameter(java.lang.String name)
Returns a named property for this Query object.- Parameters:
name
- parameter name.- Returns:
- the value for the named property (or null if not found)
-
getParameterList
public final java.util.List<java.lang.Object> getParameterList(java.lang.String name)
Returns list of values found for the named property for this Query object.- Parameters:
name
- parameter name.- Returns:
- list, which might be empty (but we never return null)
-
getParameter
public final java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)
Gets a String parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public final boolean getParameter(java.lang.String name, boolean defaultValue)
Gets a boolean parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public final int getParameter(java.lang.String name, int defaultValue)
Gets an integer parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public final long getParameter(java.lang.String name, long defaultValue)
Gets a long parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public final float getParameter(java.lang.String name, float defaultValue)
Gets a float parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public final double getParameter(java.lang.String name, double defaultValue)
Gets a double parameter.- Parameters:
name
- parameter name.defaultValue
- default value to return if not set.
-
getParameter
public java.lang.Object getParameter(java.lang.String name, java.lang.Object defaultValue)
Gets a parameter.- Parameters:
name
- name of parameter to return.defaultValue
- default value to return if not set.
-
setParameters
public final void setParameters(java.util.Map<java.lang.String,java.lang.Object> value)
-
setParameters
public void setParameters(java.util.Map<java.lang.String,java.lang.Object> params, boolean override)
Copies parameters from a Map into this Query.- Parameters:
params
- the parameters to copy into this Query instance.override
- indicates if parameters from params should overwrite existing parameters in this Query
-
parseIntParameter
protected static int parseIntParameter(java.lang.Object value, int defaultValue)
-
removeParameter
public java.lang.Object removeParameter(java.lang.String name)
Remove the value for a parameter for this Query object.- Parameters:
name
- the parameter to remove.
-
setEnumParameter
protected final void setEnumParameter(java.lang.String key, java.lang.Object value, java.lang.String... enumValues)
Internal method for setting an object parameter.NOTE: enumValues must contain lower case strings.
-
setStringParameter
protected final void setStringParameter(java.lang.String key, java.lang.Object value)
Internal method for setting a string parameter.
-
setIntegerParameter
protected final void setIntegerParameter(java.lang.String key, java.lang.Object value)
Internal method for setting an integer parameter.
-
setUnsignedParameter
protected final void setUnsignedParameter(java.lang.String key, java.lang.Object value)
Internal method for setting an integer parameter.
-
setBooleanParameter
protected final void setBooleanParameter(java.lang.String key, java.lang.Object value)
Internal method for setting a boolean parameter.
-
setRollupParameter
protected final void setRollupParameter(java.lang.String key, java.lang.Object value)
-
appendParameter
protected static void appendParameter(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add ", \"name
\"=\"value
\"" tobuffer
.
-
addParameter
protected static void addParameter(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add "\"name
\"=\"value
\"" tobuffer
.
-
addParameterCompact
protected static void addParameterCompact(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)
Add "\"name
\"=\"value
\"" tobuffer
, omitting value if it is Boolean.TRUE.
-
escape
protected static void escape(java.lang.StringBuilder buffer, java.lang.Object value)
-
escape
protected void escape(java.lang.StringBuilder buffer, java.lang.String value, boolean quote)
Helper method to escape a string for toString() .- Parameters:
buffer
- buffer to write escaped value tovalue
- the value to escapequote
- if true, escaped value will be wrapped in double quotes.
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toString
public final java.lang.String toString(boolean compact)
-
prettyPrint
public final void prettyPrint()
Sends a hierarchical representation of this query to standard out.
-
prettyPrint
public final void prettyPrint(java.io.PrintStream out)
Sends a hierarchical representation of this query specified PrintStream.- Parameters:
out
- stream to output query representation to
-
prettyFormat
public final java.lang.String prettyFormat()
Returns a hierarchical representation of this query as a string.
-
indent
protected static java.lang.StringBuilder indent(java.lang.StringBuilder buffer, int indent)
Support method to indent a "line" in a StringBuilder.
-
-