Property | Description | Default | Type | Required | QPL Config? |
---|---|---|---|---|---|
enable | Enable stage for execution | true | boolean | No | No |
name | Name for this specific stage | "vector" | 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 |
halt_on_exception | Indicates if the pipeline should be interrupted in case of an exception | true | boolean | No | No |
fields | Fields to be used for matching terms, phrases, spans, etc. | array, object, or string | Yes | Yes | |
model | Enum | Yes | No | ||
vector_field_name | string | Yes | No |
The 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. |
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
The QueryStageUIConfig is a configuration object that provides UI-specific settings for the QueryStage.
Property | Description | Default | Type |
---|---|---|---|
page_size | Configuration for page size settings in the UI | Vector | No |
sort | Configuration for sort settings in the UI | Vector | No |
Property | Description | Default | Type |
---|---|---|---|
default | Default page size value | 25 | integer |
options | Available page size options | [25, 50, 100] | array of integers |
Property | Description | Type | Required |
---|---|---|---|
default | Default sort entry | SortEntry | Yes |
options | Available sort options | array of Vector | Yes |
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 | Vector or object | Yes |
Enum Value | Description |
---|---|
"asc" | Ascending sort order |
"desc" | Descending sort order |
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 = QueryStage( 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=QueryStageUIConfig( 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] ) ) )