Property | Description | Default | Type | Required | QPL Config? |
---|---|---|---|---|---|
type | Stage class name | - | string | Yes | No |
enable | Enable stage for execution | true | boolean | No | No |
name | Name for this specific stage | "search" | string | No | No |
save_to_intermediate | If true, the result of the stage will be stored in the intermediate instead of the final section | false | boolean | No | No |
expand_result | Indicates if the result of this stage should be expanded into the final data dictionary instead of being appended as usual | false | boolean | No | No |
ui_only | Section specific for UI configuration that affects the process of the stage | QueryQueryStageUIConfig | No | No | |
halt_on_exception | Indicates if the pipeline should be interrupted in case of an exception | true | boolean | No | No |
index | Name of the index or alias in which to perform the query | - | string or array of strings | Yes | No |
engine_name | Name of the engine to use for this query. If none is provided, the default engine will be used | string | No | No | |
query | JSON Query DSL as a string representation or a dictionary | string or object | No | No | |
size | Number of hits to return per request | integer | No | No | |
sort | Sort configuration for the query results | array or object | No | No | |
page_size_default | Default page size for pagination | 25 | integer | No | No |
operator | The default operator for query string query: AND or OR | "or" | string | No | No |
highlight | Name of the key in which the highlights will be stored in the intermediate | "highlight" | string | No | No |
filters | Name of the key in which the filters will be stored in the intermediate | "filters" | string | No | No |
aggregations | Name of the key in which the engine specific aggregations will be stored in the intermediate | "aggregations" | string | No | No |
aggregations_filters | Name of the key in which the engine specific aggregation filters will be stored in the intermediate | "aggregations_filters" | string | No | No |
fetch_fields | List of fields to fetch | array of strings | No | ||
exclude_fields | List of fields to exclude | array of strings | No | ||
qpl_enable | Enable QPL to parse the "q" parameter into an engine query with pyQPL | false | boolean | No | Yes |
implicit_operator | Default operator to use when the relationship between two operands is ambiguous | "or" | string | No | Yes |
fields | Fields to be used for matching terms, phrases, spans, etc. | array, object, or string | Yes | Yes | |
date_fields | Fields to be used for date ranges | array, object, or string | No | Yes | |
range_fields | Fields to be used for ranges | array, object, or string | No | Yes | |
date_format | Date format used to convert date values in the query | string | No | Yes | |
slop_near | Slop value used for the NEAR operator | 10 | number | No | Yes |
slop_before | Slop value used for the BEFORE operator | 2 | number | No | Yes |
slop_adj | Slop value used for the ADJ operator | 0 | number | No | Yes |
slop_span_not | Slop value used for the SPAN NOT operator | 0 | number | No | Yes |
timezone | Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query to UTC | string | No | Yes | |
wildcard | Use wildcard operators | false | boolean | No | Yes |
grammar | File path or raw string representing the grammar for parsing text into QPL | string | No | Yes | |
custom_operators | Dictionary of custom operators with their names as keys and corresponding logic classes as values | object | No | Yes | |
synonyms_call | Function returning requested synonyms for the specified string | Callable(accepts: string, returns: list of string, or None ) | No | Yes |
The Execute Query Stage offers a range of parameters that can be passed via the intermediate input to customize your search request or modify the configuration of the current stage. These parameters provide flexibility and control over the search process.
Parameter | Description |
---|---|
q | A string query for performing a search. Can be transformed into engine-specific queries using PyQPL (Query Parser Language). |
query | Engine-specific queries for the search. |
knn | Engine-specific queries specifically for k-nearest neighbor (KNN) searches. |
size | Number of results to return from the search request. Overrides the size specified in the configuration. |
from/start | Indicates the starting point for retrieving search results. Can be used interchangeably with the page parameter. |
page | It can be an alternative to from/start. It calculates the start based on the size parameter |
fetch_fields | List of fields to fetch for each search result. Overrides the fields specified in the configuration. |
exclude_fields | List of fields to exclude from the search results. Overrides the fields specified in the configuration. |
scroll | Scroll ID used to retrieve large numbers of results from a single search request, similar to a cursor in a traditional database. |
operator | The default operator for query string queries: AND or OR . Overrides the default operator specified in the configuration. |
Tip |
---|
Remember that the intermediate can be fill with either other stages or the original request body that trigger the pipeline, making this essentially REST API parameters |
Anchor |
---|
|
|
The QueryStageUIConfig ExecuteQueryStageUIConfig is a configuration object that provides UI-specific settings for the QueryStage.
QueryStageUIConfigProperty | Description | Default | Type |
---|---|---|---|
page_size | Configuration for page size settings in the UI | QueryPageSizeConfig | No |
sort | Configuration for sort settings in the UI | QuerySortConfig | No |
Anchor | ||||
---|---|---|---|---|
|
Property | Description | Default | Type |
---|---|---|---|
default | Default page size value | 25 | integer |
options | Available page size options | [25, 50, 100] | array of integers |
Anchor | ||||
---|---|---|---|---|
|
Property | Description | Type | Required |
---|---|---|---|
default | Default sort entry | SortEntry | Yes |
options | Available sort options | array of Query SortEntry | Yes |
Anchor | ||||
---|---|---|---|---|
|
Property | Description | Type | Required |
---|---|---|---|
field | Name of the field to be used for sorting | string | Yes |
display_name | Display name for this sort entry (only applicable for user interface) | string | No |
order | Sort order to be used | Query SortOrder or object | Yes |
Anchor | ||||
---|---|---|---|---|
|
Enum Value | Description |
---|---|
"asc" | Ascending sort order |
"desc" | Descending sort order |
Code Block | ||||
---|---|---|---|---|
| ||||
synonyms = { 'cancer': ['cancer', 'malignancy', '363346000', 'cancers', 'malignancies', '"malignant growth"', '"malignant neoplasm"', '"malignant neoplasms"', '"malignant neoplastic disease"', '"malignant tumor"', '"malignant tumors"', '"neoplasm malignant"', '"neoplasm/cancer"', '"tumor, malignant"'], 'headache': ['headache', '25064002', 'cephalalgia', 'cephalgia', 'cephalgias', '"cranial pain"', '"have headaches"', '"head ache"', '"head pain"', '"head pain cephalgia"', '"head pains"', 'headaches', '"mild global headache"', '"mild headache"', '"pain head"', '"pain in head"', '"pain, head"'] } _query_stage = QueryStageExecuteQueryStage( engine_name=DEFAULT_ENGINE_NAME, enable=True, qpl_enable=True, name=SEARCH_STAGE_NAME, index='movies', synonyms_call= lambda x: self.synonyms.get(x, None), # Simple synonym implementation wildcard=False, fields=['title', 'overview', 'url', 'status', 'metadata', 'metadata.production_companies', 'metadata.cast', 'metadata.directors'], range_fields=['metadata.budget'], date_fields=['release_date'], fetch_fields=['title', 'adult', 'overview', 'url', 'release_date', 'status', 'video', 'metadata', 'metadata.production_companies', 'metadata.cast', 'metadata.directors'], exclude_fields=None, implicit_operator='or', page_size_default=25, sort=SortEntry( field='_score', order=SortOrder.DESC ), aggregations=_aggregation_stage.name, aggregations_filters=_aggregation_stage.filters_name, highlight=_highlight_stage.name, filters=_filter_stage.name, ui_only=QueryStageUIConfigExecuteQueryStageUIConfig( sort=SortConfig( default=SortEntry( field='_score', display_name='Score', order=SortOrder.DESC ), options=[ SortEntry( field='_score', display_name='Score', order=SortOrder.DESC ), SortEntry( field='release_date', display_name='Release Date', order=SortOrder.ASC ), SortEntry( field='metadata.budget', display_name='Budget', order=SortOrder.DESC ) ] ), page_size=PageSizeConfig( default=25, options=[25, 50, 100] ) ) ) |