Class: Query

Query


new Query()

Solr Query

Methods


addParams(params)

Add params

Parameters:
Name Type Description
params Array.<Object>
Properties
Name Type Description
field String

params field

value String

params value

Returns:
Type
Query

df(params)

Set the default query field.

Parameters:
Name Type Description
params String

default field for search

Returns:
Type
Query

dismax()

Set DisMax query parser

Returns:
Type
Query

edismax()

Set eDisMax query parser

Returns:
Type
Query

facetQuery(params)

Set facet query params

Parameters:
Name Type Description
params Object | String

facet object or facet string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off facet

query String <optional>

Specifies a Lucene query to generate a facet count.

field String | Array <optional>

Identifies a field to be treated as a facet.

prefix String <optional>

Limits the terms used for faceting to those that begin with the specified prefix.

contains String <optional>

Limits the terms used for faceting to those that contain the specified substring.

containsIgnoreCase String <optional>

If facet.contains is used, ignore case when searching for the specified substring.

sort String <optional>

Controls how faceted results are sorted. (count|index)

limit Number <optional>

Controls how many constraints should be returned for each facet.

offset Number <optional>

Specifies an offset into the facet results at which to begin displaying facets.

mincount Number <optional>

Specifies the minimum counts required for a facet field to be included in the response.

missing Boolean <optional>

Controls whether Solr should compute a count of all matching results which have no value for the field, in addition to the term-based constraints of a facet field.

method String <optional>

Selects the algorithm or method Solr should use when faceting a field. (enum|fc|fcs)

Returns:
Type
Query

fl(params)

Set field params

Parameters:
Name Type Description
params String | Array.<String>

field name

Returns:
Type
Query

fq(params)

Set filter query params

Parameters:
Name Type Description
params Object | Array.<Object>

filter options

Properties
Name Type Argument Description
field String <optional>

filter field

value String | Number <optional>

filter value

Returns:
Type
Query

groupQuery(params)

Set group query params

Parameters:
Name Type Description
params Object | String

group object or group string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off group

field String <optional>

The name of the field by which to group results.

query String <optional>

Return a single group of documents that match the given query.

limit Number <optional>

Specifies the number of results to return for each group. The default value is 1.

offset Number <optional>

Specifies an initial offset for the document list of each group.

sort String <optional>

Specifies how Solr sorts documents within each group.

format String <optional>

If this parameter is set to simple, the grouped documents are presented in a single flat list, and the start and rows parameters affect the numbers of documents instead of groups.

main Boolean <optional>

If true, the result of the first field grouping command is used as the main result list in the response, using group.format=simple.

ngroups Boolean <optional>

If true, Solr includes the number of groups that have matched the query in the results. The default value is false.

truncate Boolean <optional>

If true, facet counts are based on the most relevant document of each group matching the query. The default value is false.

facet Boolean <optional>

Determines whether to compute grouped facets for the field facets specified in facet.field parameters.

cachePercent Number <optional>

Determines whether to compute grouped facets for the field facets specified in facet.field parameters.

Returns:
Type
Query

hlQuery(params)

Set hl query params

Parameters:
Name Type Description
params Object | String

hl object or hl string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off hl

q String <optional>

Specifies an overriding query term for highlighting

qparser String <optional>

Specifies a qparser to use for the hl.q query.

fl String | Array <optional>

Specifies a list of fields to highlight.

snippets Number <optional>

Specifies maximum number of highlighted snippets to generate per field.

fragsize Number <optional>

Specifies the size, in characters, of fragments to consider for highlighting.

mergeContiguous Boolean <optional>

Instructs Solr to collapse contiguous fragments into a single fragment.

requireFieldMatch Boolean <optional>

If set to true, highlights terms only if they appear in the specified field.

maxAnalyzedChars Number <optional>

Specifies the number of characters into a document that Solr should look for suitable snippets.

maxMultiValuedToExamine Number <optional>

Specifies the maximum number of entries in a multi-valued field to examine before stopping.

maxMultiValuedToMatch Number <optional>

Specifies the maximum number of matches in a multi-valued field that are found before stopping.

alternateField String <optional>

Specifies a field to be used as a backup default summary if Solr cannot generate a snippet (i.e., because no terms match).

maxAlternateFieldLength Number <optional>

Specifies the maximum number of characters of the field to return.

formatter String <optional>
simple

Selects a formatter for the highlighted output.

simplePre String <optional>

Specifies the text that should appear before. ()

simplePost String <optional>

Specifies the text that should appear after. ()

fragmenter String <optional>

Specifies a text snippet generator for highlighted text.

usePhraseHighlighter Boolean <optional>

If set to true, Solr will use the Lucene SpanScorer class to highlight phrase terms only when they appear within the query phrase in the document.

highlightMultiTerm Boolean <optional>

If set to true, Solr will use highlight phrase terms that appear in multi-term queries.

regexSlop Number <optional>

When using the regex fragmenter (hl.fragmenter =regex), this parameter defines the factor by which the fragmenter can stray from the ideal fragment size (given by hl.fragsize) to accommodate a regular expression.

regexPattern String <optional>

Specifies the regular expression for fragmenting. This could be used to extract sentences.

regexMaxAnalyzedChars Number <optional>

Instructs Solr to analyze only this many characters from a field when using the regex fragmenter (after which, the fragmenter produces fixed-sized fragments).

preserveMulti Boolean <optional>

If true, multi-valued fields will return all values in the order they were saved in the index. If false, only values that match the highlight request will be returned.

Returns:
Type
Query

mltQuery(params)

Set mlt query params

Parameters:
Name Type Description
params Object | String

mlt object or mlt string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off mlt

fl String | Array <optional>

Specifies the fields to use for similarity. If possible, these should have stored termVectors.

mintf Number <optional>

Specifies the Minimum Term Frequency, the frequency below which terms will be ignored in the source document.

mindf Number <optional>

Specifies the Minimum Document Frequency, the frequency at which words will be ignored which do not occur in at least this many documents.

maxdf Number <optional>

Specifies the Maximum Document Frequency, the frequency at which words will be ignored which occur in more than this many documents.

minwl Number <optional>

Sets the minimum word length below which words will be ignored.

maxwl Number <optional>

Sets the maximum word length above which words will be ignored.

maxqt Number <optional>

Sets the maximum number of query terms that will be included in any generated query.

maxntp Number <optional>

Sets the maximum number of tokens to parse in each example document field that is not stored with TermVector support.

boost Boolean <optional>

Specifies if the query will be boosted by the interesting term relevance. It can be either "true" or "false".

qf String <optional>

Query fields and their boosts using the same format as that used by the DisMaxRequestHandler. These fields must also be specified in mlt.fl.

count Number <optional>

Specifies the number of similar documents to be returned for each result. The default value is 5.

matchInclude Boolean <optional>

Specifies whether or not the response should include the matched document. If set to false, the response will look like a normal select response.

matchOffset Number <optional>

Specifies an offset into the main query search results to locate the document on which the MoreLikeThis query should operate. By default, the query operates on the first result for the q parameter.

interestingTerms String <optional>

Controls how the MoreLikeThis component presents the "interesting" terms (the top TF/IDF terms) for the query. ("list"|"details"|"none")

Returns:
Type
Query

q(params)

Set query params

Parameters:
Name Type Description
params Object | String

query object or query string

Properties
Name Type Argument Description
str String <optional>

native str query ( ex) '(name:test OR category:test)' )

Returns:
Type
Query

qop(params)

Set default query operator

Parameters:
Name Type Description
params String

default operator('AND'|'OR')

Returns:
Type
Query

rows(params)

Set rows params

Parameters:
Name Type Description
params Number

size number

Returns:
Type
Query

sort(params)

Set sort params

Parameters:
Name Type Description
params Object

sort options

Returns:
Type
Query

spellcheckQuery(params)

Set spellcheck query params

Parameters:
Name Type Description
params Object | String

spell object or spell string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off spell

q String <optional>

Selects the query to be spellchecked.

build Boolean <optional>

Instructs Solr to build a dictionary for use in spellchecking.

collate Boolean <optional>

Causes Solr to build a new query based on the best suggestion for each term in the submitted query.

maxCollations Number <optional>

This parameter specifies the maximum number of collations to return.

maxCollationTries Number <optional>

This parameter specifies the number of collation possibilities for Solr to try before giving up.

maxCollationEvaluations Number <optional>

This parameter specifies the maximum number of word correction combinations to rank and evaluate prior to deciding which collation candidates to test against the index.

collateExtendedResults Boolean <optional>

If true, returns an expanded response detailing the collations found. If s pellcheck.collate is false, this parameter will be ignored.

collateMaxCollectDocs Number <optional>

The maximum number of documents to collect when testing potential Collations

count Number <optional>

Specifies the maximum number of spelling suggestions to be returned.

dictionary String <optional>

Specifies the dictionary that should be used for spellchecking.

extendedResults Boolean <optional>

Causes Solr to return additional information about spellcheck results, such as the frequency of each original term in the index (origFreq) as well as the frequency of each suggestion in the index (frequency).

onlyMorePopular Boolean <optional>

Limits spellcheck responses to queries that are more popular than the original query.

maxResultsForSuggest Number <optional>

The maximum number of hits the request can return in order to both generate spelling suggestions and set the "correctlySpelled" element to "false".

alternativeTermCount Number <optional>

The count of suggestions to return for each query term existing in the index and/or dictionary.

reload Boolean <optional>

Reloads the spellchecker.

accuracy Number <optional>

Specifies an accuracy value to help decide whether a result is worthwhile. The value is a float between 0 and 1.

Returns:
Type
Query

start(params)

Set start params

Parameters:
Name Type Description
params Number

offset number

Returns:
Type
Query

termsQuery(params)

Set terms query params

Parameters:
Name Type Description
params Object | String

terms object or terms string

Properties
Name Type Argument Default Description
on Boolean <optional>
true

Turn on or off terms

fl String

The name of the field to get the terms from.

lower String <optional>

The term to start at. If not specified, the empty string is used, meaning start at the beginning of the field.

lowerIncl Boolean <optional>

The term to start at. Include the lower bound term in the result set. Default is true.

mincount Number <optional>

The minimum doc frequency to return in order to be included.

maxcount Number <optional>

The maximum doc frequency.

prefix String <optional>

Restrict matches to terms that start with the prefix.

regex String <optional>

Restrict matches to terms that match the regular expression.

regexFlag String <optional>

Flags to be used when evaluating the regular expression defined in the "terms.regex" parameter.(case_insensitive|comments|multiline|literal|dotall|unicode_case|canon_eq|unix_lines)

limit Number <optional>

The maximum number of terms to return.

upper String <optional>

The term to stop at. Either upper or terms.limit must be set.

upperIncl Boolean <optional>

Include the upper bound term in the result set. Default is false.

raw Boolean <optional>

If true, return the raw characters of the indexed term, regardless of if it is human readable.

sort String <optional>

If count, sorts the terms by the term frequency (highest count first). If index, returns the terms in index order.(count|index)

Returns:
Type
Query

toString()

Make query to string

Returns:
Type
String

wt(params)

Set the response type.

Parameters:
Name Type Description
params String

response type (json|xml)

Returns:
Type
Query