queryParser
Request-time query parser definitions or references to the project descriptor's query parsers.
The following query​Parser:​*
component types are available for use in analysis request JSONs:
-
query​Parser:​enhanced
-
An enhanced query parser component definition.
-
query​Parser:​project
-
A reference to one of the query parsers declared in the project descriptor's query parsers block.
query​Parser:​reference
-
References a
query​Parser:​*
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
query​Parsers:​project
.
query​Parser:​enhanced
This query parser implements an enhanced syntax of Lucene's (flexible) Standard​Query​Parser
. 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"
}
default​Fields
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 default​Fields
was equal to
["title", "abstract"]
, Lingo4G would rewrite the query to
(summary:​foo ​O​R description:​bar) title:​bar
.
If you do not provide default​Fields
or set it to an empty array, Lingo4G will raise errors for
queries containing terms without explicit field qualifiers.
default​Operator
The default Boolean operator Lingo4G applies to each clause of the query, unless you explicitly provide the operator to use.
For example, with the default​Operator
equal to A​N​D
, Lingo4G rewrites the
data mining
query to data ​A​N​D mining
.
The default​Operator
property supports the following values:
O​R
-
Disjunction operator.
A​N​D
-
Conjunction operator.
sanitize​Non​Spaces
Before parsing the query, Lingo4G removes all occurrences matching the regular expression pattern you provide in
the
sanitize​Non​Spaces
property. The default pattern removes zero-width spaces. To disable the
replacement, set sanitize​Non​Spaces
to an empty string.
sanitize​Spaces
Before parsing the query, Lingo4G replaces each occurrence of the regular expression pattern you provide in the
sanitize​Spaces
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
sanitize​Spaces
to an empty string.
validate​Fields
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.
query​Parser:​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
query​Parsers:​project
.
query​Parser​Key
The key of the query parser to use from the queryParsers section of the project descriptor.
query​Parser:​*
Consumers of
The following stages and components take query​Parser:​*
as
input:
Stage or component | Property |
---|---|
query:​string | query​Parser |
query​Builder:​string | query​Parser |