Class: SearchQuery

SearchQuery


new SearchQuery()

Class for building of FTS search queries. This class should never be constructed directly, instead you should use the SearchQuery.new static method to instantiate a SearchQuery.

Since:
  • 2.1.7 (stability: committed)

Classes

BooleanFieldQuery
BooleanQuery
ConjunctionQuery
DateRangeQuery
DisjunctionQuery
DocIdQuery
GeoBoundingBoxQuery
GeoDistanceQuery
MatchAllQuery
MatchNoneQuery
MatchPhraseQuery
MatchQuery
NumericRangeQuery
PhraseQuery
PrefixQuery
QueryStringQuery
RegexpQuery
TermQuery
TermRangeQuery
WildcardQuery

Members


<static, readonly> Consistency :number

Enumeration for specifying FTS consistency semantics.

Type:
  • number
Properties:
Name Type Default Description
NOT_BOUNDED number 1

This is the default (for single-statement requests).


<static, readonly> HighlightStyle :number

Enumeration for specifying FTS highlight styling.

Type:
  • number
Properties:
Name Type Default Description
DEFAULT number undefined

This causes hits to be highlighted using the default style.

HTML number html

This causes hits to be highlighted using HTML tags.

ANSI number ansi

This causes hits to be highlighted with ANSI character codes.

Methods


<static> boolean()

boolean creates a compound BooleanQuery composed of several other Query objects.

Returns:
Type
SearchQuery.BooleanQuery

<static> booleanField(val)

booleanField creates a BooleanFieldQuery for searching boolean fields in an index.

Parameters:
Name Type Description
val boolean
Returns:
Type
SearchQuery.BooleanFieldQuery

<static> conjuncts(queries)

conjuncts creates a ConjunctionQuery for matching all of a list of subqueries in an index.

Parameters:
Name Type Description
queries Array.<SearchQuery.Query>
Returns:
Type
SearchQuery.ConjunctionQuery

<static> dateRange()

dateRange creates a DateRangeQuery for matching date ranges in an index.

Returns:
Type
SearchQuery.DateRangeQuery

<static> disjuncts(queries)

disjuncts creates a DisjunctionQuery for matching any of a list of subqueries in an index.

Parameters:
Name Type Description
queries Array.<SearchQuery.Query>
Returns:
Type
SearchQuery.DisjunctionQuery

<static> docIds(ids)

docIds creates a DocIdQuery which allows you to match a list of document ids in an index.

Parameters:
Name Type Description
ids Array.<string>
Returns:
Type
SearchQuery.DocIdQuery

<static> geoBoundingBoxQuery(tl_lon, tl_lat, br_lon, br_lat)

geoBoundingBoxQuery creates a geographical bounding-box based query.

Parameters:
Name Type Description
tl_lon number

Top-left longitude

tl_lat number

Top-left latitude

br_lon number

Bottom-right longitude

br_lat number

Bottom-right latitude

Returns:
Type
SearchQuery.GeoBoundingBoxQuery

<static> geoDistanceQuery(lon, lat, distance)

geoDistanceQuery creates a geographical distance based query.

Parameters:
Name Type Description
lon number

The center longitude

lat number

The center latitude

distance string

The radius to search within (ex: 100mi)

Returns:
Type
SearchQuery.GeoDistanceQuery

<static> match(match)

match creates a Query MatchQuery matching text.

Parameters:
Name Type Description
match string
Returns:
Type
SearchQuery.MatchQuery

<static> matchAll()

matchAll creates a MatchAllQuery which matches anything.

Returns:
Type
SearchQuery.MatchAllQuery

<static> matchNone()

matchNone creates a MatchNoneQuery which matches nothing.

Returns:
Type
SearchQuery.MatchNoneQuery

<static> matchPhrase(phrase)

matchPhase creates a new MatchPhraseQuery object for matching phrases in the index.

Parameters:
Name Type Description
phrase string
Returns:
Type
SearchQuery.MatchPhraseQuery

<static> new(indexName, query)

Creates a new search query from an index name and search query definition.

Parameters:
Name Type Description
indexName string
query SearchQuery.Query
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

<static> numericRange()

numericRange creates a NumericRangeQuery for matching numeric ranges in an index.

Returns:
Type
SearchQuery.NumericRangeQuery

<static> phrase(terms)

phrase creates a new PhraseQuery for searching a phrase in an index.

Parameters:
Name Type Description
terms Array.<string>
Returns:
Type
SearchQuery.PhraseQuery

<static> prefix(prefix)

prefix creates a new MatchQuery for searching for a prefix in an index.

Parameters:
Name Type Description
prefix string
Returns:
Type
SearchQuery.PrefixQuery

<static> queryString(query)

string creates a QueryStringQuery for matching strings.

Parameters:
Name Type Description
query string
Returns:
Type
SearchQuery.QueryStringQuery

<static> regexp(regexp)

regexp creates a new RegexpQuery object for matching against a regexp query in the index.

Parameters:
Name Type Description
regexp string
Returns:
Type
SearchQuery.RegexpQuery

<static> term(term)

term creates a TermQuery for searching terms in an index.

Parameters:
Name Type Description
term string
Returns:
Type
SearchQuery.TermQuery

<static> termRange()

termRange creates a TermRangeQuery for matching term ranges in an index.

Returns:
Type
SearchQuery.TermRangeQuery

<static> wildcard(wildcard)

wildcard creates a WildcardQuery which allows you to match a string with wildcards in an index.

Parameters:
Name Type Description
wildcard string
Returns:
Type
SearchQuery.WildcardQuery

addFacet(name, facet)

Adds a SearchFacet object to return information about as part of the execution of this query.

Parameters:
Name Type Description
name string
facet SearchFacet
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

consistency(val)

Specify the consistency level for this query.

Parameters:
Name Type Description
val SearchQuery.Consistency
Since:
  • 2.2.3 (stability: committed)
Returns:
Type
SearchQuery

consistentWith(state)

Specifies a MutationState object to ensure this query is consistent with.

Parameters:
Name Type Description
state
Since:
  • 2.2.3 (stability: uncommitted)

explain(explain)

Includes information about the internal search semantics used to execute your query.

Parameters:
Name Type Description
explain boolean
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

fields(fields)

Specifies the fields you wish to receive in the result set.

Parameters:
Name Type Description
fields Array.<string>
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

highlight(style, fields)

Requests a particular highlight style and field list for this query.

Parameters:
Name Type Description
style SearchQuery.HighlightStyle
fields Array.<string>
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

limit(limit)

Specifies the maximum number of results to return.

Parameters:
Name Type Description
limit number
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

skip(skip)

Specifies how many results to skip from the beginning of the result set.

Parameters:
Name Type Description
skip number
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery

sort(fields)

Specifies the fields you wish to sort by in your result set.

Parameters:
Name Type Description
fields Array.<(string|SearchSort)>
Since:
  • 2.3.0 (stability: committed)
Returns:
Type
SearchQuery

timeout(timeout)

Specifies the maximum time to wait (in millseconds) for this query to complete.

Parameters:
Name Type Description
timeout number
Since:
  • 2.1.7 (stability: committed)
Returns:
Type
SearchQuery