The Execute Semantic Search is the final stage of the process involving the Vector Stage and the Create Query Stage. Is in charge of executing the search and returning the results to the UI.

Properties

PropertyDescriptionDefaultTypeRequiredQPL Config?
typeStage class name-stringYesNo
enableEnable stage for executiontruebooleanNoNo
nameName for this specific stage"search"stringNoNo
save_to_intermediateIf true, the result of the stage will be stored in the intermediate instead of the final sectionfalsebooleanNoNo
expand_resultIndicates if the result of this stage should be expanded into the final data dictionary instead of being appended as usualfalsebooleanNoNo
ui_onlySection specific for UI configuration that affects the process of the stage-QueryStageUIConfigNoNo
halt_on_exceptionIndicates if the pipeline should be interrupted in case of an exceptiontruebooleanNoNo
indexName of the index or alias in which to perform the query-string or array of stringsYesNo
engine_nameName of the engine to use for this query. If none is provided, the default engine will be used-stringNoNo
sizeNumber of hits to return per request-integerNoNo
sortSort configuration for the query results-array or objectNoNo
page_size_defaultDefault page size for pagination25integerNoNo
operatorThe default operator for query string query: AND or OR"or"stringNoNo
highlightName of the key in which the highlights will be stored in the intermediate"highlight"stringNoNo
aggregationsName of the key in which the engine specific aggregations will be stored in the intermediate"aggregations"stringNoNo
aggregations_filtersName of the key in which the engine specific aggregation filters will be stored in the intermediate"aggregations_filters"stringNoNo
fetch_fieldsList of fields to fetch-array of stringsNo
exclude_fieldsList of fields to exclude-array of stringsNo
fieldsFields to be used for matching terms, phrases, spans, etc.-array, object, or stringYesYes
date_fieldsFields to be used for date ranges-array, object, or stringNoYes
range_fieldsFields to be used for ranges-array, object, or stringNoYes
date_formatDate format used to convert date values in the query-stringNoYes


Execute Semantic Search Stage Intermediate Parameters

The Execute Semantic Search 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.


ParameterDescription
qA string query for performing a search. Can be transformed into engine-specific queries using PyQPL (Query Parser Language).
queryEngine-specific queries for the search.
knnEngine-specific queries specifically for k-nearest neighbor (KNN) searches.
filtersCalculated filters for search. This with knn parameter get stored on the same variable as a tuple, this is the second parameter of the tuple.
sizeNumber of results to return from the search request. Overrides the size specified in the configuration.
from/startIndicates the starting point for retrieving search results. Can be used interchangeably with the page parameter.
pageIt can be an alternative to from/start. It calculates the start based on the size parameter
fetch_fieldsList of fields to fetch for each search result. Overrides the fields specified in the configuration.
exclude_fieldsList of fields to exclude from the search results. Overrides the fields specified in the configuration.
scrollScroll ID used to retrieve large numbers of results from a single search request, similar to a cursor in a traditional database.
operatorThe default operator for query string queries: AND or OR. Overrides the default operator specified in the configuration.
vectorCalculated vectors use to create the knn query.

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

Additional Classes for Configuration

ExecuteSemanticSearchUIConfig

The ExecuteSemanticSearchStageUIConfig is a configuration object that provides UI-specific settings for the QueryStage.

QueryStageUIConfig Properties

PropertyDescriptionDefaultType
page_sizeConfiguration for page size settings in the UIPageSizeConfigNo
sortConfiguration for sort settings in the UISortConfigNo

PageSizeConfig Properties 

PropertyDescriptionDefaultType
defaultDefault page size value25integer
optionsAvailable page size options[25, 50, 100]array of integers

SortConfig Properties 

PropertyDescriptionTypeRequired
defaultDefault sort entrySortEntryYes
optionsAvailable sort optionsarray of SortEntryYes

SortEntry Properties 

PropertyDescriptionTypeRequired
fieldName of the field to be used for sortingstringYes
display_nameDisplay name for this sort entry (only applicable for user interface)stringNo
orderSort order to be usedSortOrder or objectYes

SortOrder Enum 

Enum ValueDescription
"asc"Ascending sort order
"desc"Descending sort order




Example Configuration

_search_stage = ExecuteSemanticSearchStage(
    enable=True,
    save_to_intermediate=True,
    expand_result=False,
    halt_on_exception=False,
    name=SEARCH_STAGE_NAME,
    engine_name='Elasticsearch',
    index='movies',
    sort=None,
    page_size_default=25,
    fetch_fields=[
        'title',
        'overview'
    ],
    ui_only=ExecuteSemanticSearchStageUIConfig(
        sort=SortConfig(
            default=SortEntry(
                field='_score',
                display_name='Score',
                order=SortOrder.DESC
            ),
            options=[
                SortEntry(
                    field='_score',
                    display_name='Best Match',
                    order=SortOrder.DESC
                ),
                SortEntry(
                    field='title',
                    display_name='Alphabetical: A to Z',
                    order=SortOrder.ASC
                ),
                SortEntry(
                    field='title',
                    display_name='Alphabetical: Z to A',
                    order=SortOrder.DESC
                )
            ]
        ),
        page_size=PageSizeConfig(
            default=25,
            options=[25, 50, 100]
        )
    ),
    exclude_fields=None,
    fields=[
        'title',
        'overview'
    ]
)
  • No labels