queryParser
Request-time query parser definitions or references to the project descriptor's query parsers.
The following queryParser:* component types are available for use in analysis request JSONs:
-
queryParser:enhanced -
An enhanced query parser component definition.
-
queryParser:project -
A reference to one of the query parsers declared in the project descriptor's query parsers block.
queryParser:reference-
References a
queryParser:*component defined in the request or in the project's default components.
In Lingo4G API v2, query parser definitions should be placed in the
shared components section of the project descriptor. Query
parsers in the queryParsers section of the project descriptor
are for backward compatibility with API v1 and can be referenced using
queryParsers:project.
queryParser:enhanced
This query parser implements an enhanced syntax of Lucene's (flexible) StandardQueryParser. The
extensions include support for
interval queries.
{
"type": "queryParser:enhanced",
"defaultFields": [],
"defaultOperator": "AND",
"sanitizeNonSpaces": "(?U)[\\u200B-\\u200D]+",
"sanitizeSpaces": "(?U)[\\u001c-\\u001f\\p{IsWhite_Space}\\u2028\\u2029]+",
"validateFields": true
}Refer to the query parsers documentation for the full syntax overview.
A typical definition of this component may like this, specifying the default fields for unqualified query terms and the default Boolean operator to apply between query clauses:
"enhanced": {
"type": "queryParser:enhanced",
"defaultFields": [
"title",
"abstract"
],
"defaultOperator": "OR"
}defaultFields
An array of field names to search for query terms without an explicit field name qualifier. For example, the
data title:mining query contains one unqualified term: foo and one with an explicit
field qualifier: title:mining. If defaultFields was equal to
["title", "abstract"], Lingo4G would rewrite the query to
(summary:foo OR description:bar) title:bar.
If you do not provide defaultFields or set it to an empty array, Lingo4G will raise errors for
queries containing terms without explicit field qualifiers.
defaultOperator
The default Boolean operator Lingo4G applies to each clause of the query, unless you explicitly provide the operator to use.
For example, with the defaultOperator equal to AND, Lingo4G rewrites the
data mining query to data AND mining.
The defaultOperator property supports the following values:
OR-
Disjunction operator.
AND-
Conjunction operator.
sanitizeNonSpaces
Before parsing the query, Lingo4G removes all occurrences matching the regular expression pattern you provide in
the
sanitizeNonSpaces property. The default pattern removes zero-width spaces. To disable the
replacement, set sanitizeNonSpaces to an empty string.
sanitizeSpaces
Before parsing the query, Lingo4G replaces each occurrence of the regular expression pattern you provide in the
sanitizeSpaces property with a single space character. The default pattern normalizes any sequence
of Unicode white space characters into one plain space. To disable the replacement, set
sanitizeSpaces to an empty string.
validateFields
If true, Lingo4G raises an error if the query contains a field name qualifier referring to a field
that does not exist in the index. Field name validation ensures that accidental typos in field names result in
errors rather than empty search results.
queryParser:project
This query parser contains a reference to one of the query parsers declared in the project descriptor's query parsers block, used in API v1.
{
"type": "queryParser:project",
"queryParserKey": ""
}
We strongly recommend putting query parser definitions in the
shared components section of the project descriptor or
directly in API v2 requests. Query parsers in the
queryParsers section of the project descriptor are for
backward compatibility with API v1 and can be referenced using
queryParsers:project.
queryParserKey
The key of the query parser to use from the queryParsers section of the project descriptor.
Consumers of queryParser:*
The following stages and components take queryParser:* as
input:
| Stage or component | Property |
|---|---|
query:string | queryParser |
queryBuilder:string | queryParser |