com.algolia.search.saas
Class Query

java.lang.Object
  extended by com.algolia.search.saas.Query

public class Query
extends Object


Nested Class Summary
static class Query.QueryType
           
static class Query.RemoveWordsType
           
static class Query.TypoTolerance
           
 
Field Summary
protected  boolean advancedSyntax
           
protected  boolean allowTyposOnNumericTokens
           
protected  boolean analytics
           
protected  String aroundLatLong
           
protected  boolean aroundLatLongViaIP
           
protected  List<String> attributes
           
protected  List<String> attributesToHighlight
           
protected  List<String> attributesToSnippet
           
protected  boolean distinct
           
protected  String facetFilters
           
protected  String facets
           
protected  boolean getRankingInfo
           
protected  int hitsPerPage
           
protected  boolean ignorePlural
           
protected  String insideBoundingBox
           
protected  int maxNumberOfFacets
           
protected  int minWordSizeForApprox1
           
protected  int minWordSizeForApprox2
           
protected  String numerics
           
protected  String optionalWords
           
protected  int page
           
protected  String query
           
protected  Query.QueryType queryType
           
protected  Query.RemoveWordsType removeWordsIfNoResult
           
protected  boolean replaceSynonyms
           
protected  String restrictSearchableAttributes
           
protected  boolean synonyms
           
protected  String tags
           
protected  Query.TypoTolerance typoTolerance
           
 
Constructor Summary
Query()
           
Query(Query other)
           
Query(String query)
           
 
Method Summary
 Query aroundLatitudeLongitude(float latitude, float longitude, int radius)
          Search for entries around a given latitude/longitude.
 Query aroundLatitudeLongitude(float latitude, float longitude, int radius, int precision)
          Search for entries around a given latitude/longitude.
 Query aroundLatitudeLongitudeViaIP(boolean enabled, int radius)
          Search for entries around the latitude/longitude of user (using IP geolocation)
 Query aroundLatitudeLongitudeViaIP(boolean enabled, int radius, int precision)
          Search for entries around the latitude/longitude of user (using IP geolocation)
 Query enableAnalytics(boolean enabled)
           
 Query enableAvancedSyntax(boolean advancedSyntax)
          Enable the advanced query syntax.
 Query enableDistinct(boolean distinct)
           
 Query enableReplaceSynonymsInHighlight(boolean enabled)
           
 Query enableSynonyms(boolean enabled)
           
 Query enableTyposOnNumericTokens(boolean enabled)
           
 Query enableTypoTolerance(boolean enabled)
           
 String getAroundLatLong()
           
 List<String> getAttributes()
           
 List<String> getAttributesToHighlight()
           
 List<String> getAttributesToSnippet()
           
 String getFacetFilters()
           
 String getFacets()
           
 int getHitsPerPage()
           
 String getInsideBoundingBox()
           
 int getMaxNumberOfFacets()
           
 int getMinWordSizeForApprox1()
           
 int getMinWordSizeForApprox2()
           
 String getNumerics()
           
 String getOptionalWords()
           
 int getPage()
           
 String getQuery()
           
protected  String getQueryString()
           
 Query.QueryType getQueryType()
           
 Query getRankingInfo(boolean enabled)
          if set, the result hits will contain ranking information in _rankingInfo attribute.
 Query.RemoveWordsType getRemoveWordsIfNoResult()
           
 String getRestrictSearchableAttributes()
           
 String getTags()
           
 Query.TypoTolerance getTypoTolerance()
           
 Query ignorePlural(boolean enabled)
          If set to true, plural won't be considered as a typo (for example car/cars will be considered as equals).
 Query insideBoundingBox(float latitudeP1, float longitudeP1, float latitudeP2, float longitudeP2)
          Search for entries inside a given area defined by the two extreme points of a rectangle.
 boolean isAdvancedSyntax()
           
 boolean isAllowTyposOnNumericTokens()
           
 boolean isAnalytics()
           
 boolean isAroundLatLongViaIP()
           
 boolean isDistinct()
           
 boolean isGetRankingInfo()
           
 boolean isIgnorePlural()
           
 boolean isReplaceSynonyms()
           
 boolean isSynonyms()
           
 Query removeWordsIfNoResult(Query.RemoveWordsType type)
          Select the strategy to adopt when a query does not return any result.
 Query restrictSearchableAttributes(String attributes)
          List of object attributes you want to use for textual search (must be a subset of the attributesToIndex index setting).
 Query setAttributesToHighlight(List<String> attributes)
          Specify the list of attribute names to highlight.
 Query setAttributesToRetrieve(List<String> attributes)
          Specify the list of attribute names to retrieve.
 Query setAttributesToSnippet(List<String> attributes)
          Specify the list of attribute names to Snippet alongside the number of words to return (syntax is 'attributeName:nbWords').
 Query setFacetFilters(List<String> facets)
          Filter the query by a list of facets.
 Query setFacetFilters(String facetFilters)
          Filter the query by a list of facets.
 Query setFacets(List<String> facets)
          List of object attributes that you want to use for faceting.
 Query setHitsPerPage(int nbHitsPerPage)
          Set the number of hits per page.
 Query setMaxNumberOfFacets(int n)
          Limit the number of facet values returned for each facet.
 Query setMinWordSizeToAllowOneTypo(int nbChars)
          Specify the minimum number of characters in a query word to accept one typo in this word.
 Query setMinWordSizeToAllowTwoTypos(int nbChars)
          Specify the minimum number of characters in a query word to accept two typos in this word.
 Query setNbHitsPerPage(int nbHitsPerPage)
          Deprecated. Use setHitsPerPage
 Query setNumericFilters(List<String> numerics)
          Add a list of numeric filters separated by a comma.
 Query setNumericFilters(String numerics)
          Add a list of numeric filters separated by a comma.
 Query setOptionalWords(List<String> words)
          Set the list of words that should be considered as optional when found in the query.
 Query setOptionalWords(String words)
          Set the list of words that should be considered as optional when found in the query.
 Query setPage(int page)
          Set the page to retrieve (zero base).
 Query setQueryString(String query)
          Set the full text query
 Query setQueryType(Query.QueryType type)
          Select how the query words are interpreted:
 Query setTagFilters(String tags)
          Filter the query by a set of tags.
 Query setTypoTolerance(Query.TypoTolerance typoTolerance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

protected List<String> attributes

attributesToHighlight

protected List<String> attributesToHighlight

attributesToSnippet

protected List<String> attributesToSnippet

minWordSizeForApprox1

protected int minWordSizeForApprox1

minWordSizeForApprox2

protected int minWordSizeForApprox2

getRankingInfo

protected boolean getRankingInfo

ignorePlural

protected boolean ignorePlural

distinct

protected boolean distinct

advancedSyntax

protected boolean advancedSyntax

page

protected int page

hitsPerPage

protected int hitsPerPage

restrictSearchableAttributes

protected String restrictSearchableAttributes

tags

protected String tags

numerics

protected String numerics

insideBoundingBox

protected String insideBoundingBox

aroundLatLong

protected String aroundLatLong

aroundLatLongViaIP

protected boolean aroundLatLongViaIP

query

protected String query

queryType

protected Query.QueryType queryType

optionalWords

protected String optionalWords

facets

protected String facets

facetFilters

protected String facetFilters

maxNumberOfFacets

protected int maxNumberOfFacets

analytics

protected boolean analytics

synonyms

protected boolean synonyms

replaceSynonyms

protected boolean replaceSynonyms

allowTyposOnNumericTokens

protected boolean allowTyposOnNumericTokens

removeWordsIfNoResult

protected Query.RemoveWordsType removeWordsIfNoResult

typoTolerance

protected Query.TypoTolerance typoTolerance
Constructor Detail

Query

public Query(String query)

Query

public Query()

Query

public Query(Query other)
Method Detail

removeWordsIfNoResult

public Query removeWordsIfNoResult(Query.RemoveWordsType type)
Select the strategy to adopt when a query does not return any result.


restrictSearchableAttributes

public Query restrictSearchableAttributes(String attributes)
List of object attributes you want to use for textual search (must be a subset of the attributesToIndex index setting). Attributes are separated with a comma (for example @"name,address"). You can also use a JSON string array encoding (for example encodeURIComponent("[\"name\",\"address\"]")). By default, all attributes specified in attributesToIndex settings are used to search.


setQueryType

public Query setQueryType(Query.QueryType type)
Select how the query words are interpreted:


setQueryString

public Query setQueryString(String query)
Set the full text query


setAttributesToRetrieve

public Query setAttributesToRetrieve(List<String> attributes)
Specify the list of attribute names to retrieve. By default all attributes are retrieved.


setAttributesToHighlight

public Query setAttributesToHighlight(List<String> attributes)
Specify the list of attribute names to highlight. By default indexed attributes are highlighted.


setAttributesToSnippet

public Query setAttributesToSnippet(List<String> attributes)
Specify the list of attribute names to Snippet alongside the number of words to return (syntax is 'attributeName:nbWords'). By default no snippet is computed.


enableDistinct

public Query enableDistinct(boolean distinct)
Parameters:
If - set to true, enable the distinct feature (disabled by default) if the attributeForDistinct index setting is set. This feature is similar to the SQL "distinct" keyword: when enabled in a query with the distinct=1 parameter, all hits containing a duplicate value for the attributeForDistinct attribute are removed from results. For example, if the chosen attribute is show_name and several hits have the same value for show_name, then only the best one is kept and others are removed.

enableAnalytics

public Query enableAnalytics(boolean enabled)
Parameters:
If - set to false, this query will not be taken into account in analytics feature. Default to true.

enableSynonyms

public Query enableSynonyms(boolean enabled)
Parameters:
If - set to false, this query will not use synonyms defined in configuration. Default to true.

enableReplaceSynonymsInHighlight

public Query enableReplaceSynonymsInHighlight(boolean enabled)
Parameters:
If - set to false, words matched via synonyms expansion will not be replaced by the matched synonym in highlight result. Default to true.

enableTypoTolerance

public Query enableTypoTolerance(boolean enabled)
Parameters:
If - set to false, disable typo-tolerance. Default to true.

setTypoTolerance

public Query setTypoTolerance(Query.TypoTolerance typoTolerance)
Parameters:
This - option allow to control the number of typo in the results set.

setMinWordSizeToAllowOneTypo

public Query setMinWordSizeToAllowOneTypo(int nbChars)
Specify the minimum number of characters in a query word to accept one typo in this word. Defaults to 3.


setMinWordSizeToAllowTwoTypos

public Query setMinWordSizeToAllowTwoTypos(int nbChars)
Specify the minimum number of characters in a query word to accept two typos in this word. Defaults to 7.


enableTyposOnNumericTokens

public Query enableTyposOnNumericTokens(boolean enabled)
Parameters:
If - set to false, disable typo-tolerance on numeric tokens. Default to true.

getRankingInfo

public Query getRankingInfo(boolean enabled)
if set, the result hits will contain ranking information in _rankingInfo attribute.


ignorePlural

public Query ignorePlural(boolean enabled)
If set to true, plural won't be considered as a typo (for example car/cars will be considered as equals). Default to false.


setPage

public Query setPage(int page)
Set the page to retrieve (zero base). Defaults to 0.


setHitsPerPage

public Query setHitsPerPage(int nbHitsPerPage)
Set the number of hits per page. Defaults to 10.


setNbHitsPerPage

@Deprecated
public Query setNbHitsPerPage(int nbHitsPerPage)
Deprecated. Use setHitsPerPage

Set the number of hits per page. Defaults to 10.


aroundLatitudeLongitude

public Query aroundLatitudeLongitude(float latitude,
                                     float longitude,
                                     int radius)
Search for entries around a given latitude/longitude.

Parameters:
radius - set the maximum distance in meters. Note: at indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})

aroundLatitudeLongitude

public Query aroundLatitudeLongitude(float latitude,
                                     float longitude,
                                     int radius,
                                     int precision)
Search for entries around a given latitude/longitude.

Parameters:
radius - set the maximum distance in meters.
precision - set the precision for ranking (for example if you set precision=100, two objects that are distant of less than 100m will be considered as identical for "geo" ranking parameter). Note: at indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})

aroundLatitudeLongitudeViaIP

public Query aroundLatitudeLongitudeViaIP(boolean enabled,
                                          int radius)
Search for entries around the latitude/longitude of user (using IP geolocation)

Parameters:
radius - set the maximum distance in meters. Note: at indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})

aroundLatitudeLongitudeViaIP

public Query aroundLatitudeLongitudeViaIP(boolean enabled,
                                          int radius,
                                          int precision)
Search for entries around the latitude/longitude of user (using IP geolocation)

Parameters:
radius - set the maximum distance in meters.
precision - set the precision for ranking (for example if you set precision=100, two objects that are distant of less than 100m will be considered as identical for "geo" ranking parameter). Note: at indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})

insideBoundingBox

public Query insideBoundingBox(float latitudeP1,
                               float longitudeP1,
                               float latitudeP2,
                               float longitudeP2)
Search for entries inside a given area defined by the two extreme points of a rectangle. At indexing, geoloc of an object should be set with _geoloc attribute containing lat and lng attributes (for example {"_geoloc":{"lat":48.853409, "lng":2.348800}})


setOptionalWords

public Query setOptionalWords(String words)
Set the list of words that should be considered as optional when found in the query.

Parameters:
words - The list of optional words, comma separated.

setOptionalWords

public Query setOptionalWords(List<String> words)
Set the list of words that should be considered as optional when found in the query.

Parameters:
words - The list of optional words.

setFacetFilters

public Query setFacetFilters(List<String> facets)
Filter the query by a list of facets. Each filter is encoded as `attributeName:value`.


setFacetFilters

public Query setFacetFilters(String facetFilters)
Filter the query by a list of facets. Filters are separated by commas and each facet is encoded as `attributeName:value`. To OR facets, you must add parentheses. For example: `(category:Book,category:Movie),author:John%20Doe`. You can also use a JSON string array encoding, for example `[[\"category:Book\",\"category:Movie\"],\"author:John Doe\"]`.


setFacets

public Query setFacets(List<String> facets)
List of object attributes that you want to use for faceting.
Only attributes that have been added in **attributesForFaceting** index setting can be used in this parameter. You can also use `*` to perform faceting on all attributes specified in **attributesForFaceting**.


setMaxNumberOfFacets

public Query setMaxNumberOfFacets(int n)
Limit the number of facet values returned for each facet.


setTagFilters

public Query setTagFilters(String tags)
Filter the query by a set of tags. You can AND tags by separating them by commas. To OR tags, you must add parentheses. For example tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3). At indexing, tags should be added in the _tags attribute of objects (for example {"_tags":["tag1","tag2"]} )


setNumericFilters

public Query setNumericFilters(String numerics)
Add a list of numeric filters separated by a comma. The syntax of one filter is `attributeName` followed by `operand` followed by `value. Supported operands are `<`, `<=`, `=`, `>` and `>=`. You can have multiple conditions on one attribute like for example `numerics=price>100,price<1000`.


setNumericFilters

public Query setNumericFilters(List<String> numerics)
Add a list of numeric filters separated by a comma. The syntax of one filter is `attributeName` followed by `operand` followed by `value. Supported operands are `<`, `<=`, `=`, `>` and `>=`. You can have multiple conditions on one attribute like for example `numerics=price>100,price<1000`.


enableAvancedSyntax

public Query enableAvancedSyntax(boolean advancedSyntax)
Enable the advanced query syntax. Defaults to false. - Phrase query: a phrase query defines a particular sequence of terms. A phrase query is build by Algolia's query parser for words surrounded by ". For example, "search engine" will retrieve records having search next to engine only. Typo-tolerance is disabled on phrase queries. - Prohibit operator: The prohibit operator excludes records that contain the term after the - symbol. For example search -engine will retrieve records containing search but not engine.


getQueryString

protected String getQueryString()

getAttributes

public List<String> getAttributes()
Returns:
the attributes

getAttributesToHighlight

public List<String> getAttributesToHighlight()
Returns:
the attributesToHighlight

getAttributesToSnippet

public List<String> getAttributesToSnippet()
Returns:
the attributesToSnippet

getMinWordSizeForApprox1

public int getMinWordSizeForApprox1()
Returns:
the minWordSizeForApprox1

getMinWordSizeForApprox2

public int getMinWordSizeForApprox2()
Returns:
the minWordSizeForApprox2

isGetRankingInfo

public boolean isGetRankingInfo()
Returns:
the getRankingInfo

isIgnorePlural

public boolean isIgnorePlural()
Returns:
the ignorePlural

isDistinct

public boolean isDistinct()
Returns:
the distinct

isAdvancedSyntax

public boolean isAdvancedSyntax()
Returns:
the advancedSyntax

getPage

public int getPage()
Returns:
the page

getHitsPerPage

public int getHitsPerPage()
Returns:
the hitsPerPage

getRestrictSearchableAttributes

public String getRestrictSearchableAttributes()
Returns:
the restrictSearchableAttributes

getTags

public String getTags()
Returns:
the tags

getNumerics

public String getNumerics()
Returns:
the numerics

getInsideBoundingBox

public String getInsideBoundingBox()
Returns:
the insideBoundingBox

getAroundLatLong

public String getAroundLatLong()
Returns:
the aroundLatLong

isAroundLatLongViaIP

public boolean isAroundLatLongViaIP()
Returns:
the aroundLatLongViaIP

getQuery

public String getQuery()
Returns:
the query

getQueryType

public Query.QueryType getQueryType()
Returns:
the queryType

getOptionalWords

public String getOptionalWords()
Returns:
the optionalWords

getFacets

public String getFacets()
Returns:
the facets

getFacetFilters

public String getFacetFilters()
Returns:
the facetFilters

getMaxNumberOfFacets

public int getMaxNumberOfFacets()
Returns:
the maxNumberOfFacets

isAnalytics

public boolean isAnalytics()
Returns:
the analytics

isSynonyms

public boolean isSynonyms()
Returns:
the synonyms

isReplaceSynonyms

public boolean isReplaceSynonyms()
Returns:
the replaceSynonyms

isAllowTyposOnNumericTokens

public boolean isAllowTyposOnNumericTokens()
Returns:
the allowTyposOnNumericTokens

getRemoveWordsIfNoResult

public Query.RemoveWordsType getRemoveWordsIfNoResult()
Returns:
the removeWordsIfNoResult

getTypoTolerance

public Query.TypoTolerance getTypoTolerance()
Returns:
the typoTolerance


Copyright © 2015. All rights reserved.