The Dynamic Results Stage takes the search results, typically referred to as "hits," and leverages the Dynamic Fields Framework. This framework is employed to transform these raw search results into a format that is more user-friendly and suitable for presentation within the user interface (UI).

In essence, it acts as an intermediary layer that bridges the gap between the raw, often complex search results and a more user-friendly representation. This translation process ensures that the information retrieved from the search is presented in a way that is easily comprehensible and aesthetically pleasing to users when displayed in the UI.

Unlike the other stages, the main job of this stage is developed in the post_process of the stage in the pipeline, hence this stage does not require to be immediately after the search stage. 

Properties

ParameterTypeDefaultRequiredDescription
namestr'dynamic_results'FalseName for this specific stage. Used on the intermediate and final parameters.
for_clausestr'default'FalseFor clause.
titleOptional[DynamicField]-FalseTitle information.
sub_titleOptional[DynamicField]-FalseSubtitle information.
thumbnailOptional[Union[ImageField]]-FalseThumbnail information.
headerOptional[list[list[DynamicField]]][]FalseHeader information as a grid (list of lists).
bodyOptional[list[list[DynamicField]]][]FalseBody information as a grid (list of lists).
metadataOptional[SectionFormat]-FalseMetadata information.
search_responsestr-TrueName of the key in the final result in which query results will be stored.
non_displayed_fieldsOptional[list[NonDisplayField]]-FalseList of fields to add as part of the UI response.
ignore_blanks
Optional[bool]FalseFalseFlag to ignore warnings when some dynamic values are None. (version 3.0.0^)

NonDisplayField Model

ParameterTypeDefaultRequiredDescription
fieldstr-TrueField name or path to the field from which to fetch the data.
aliasOptional[str]-FalseAlias to assign to the fetched values. If not specified, the field or path will be used as the name.

ListFormat Model

ParameterTypeDefaultRequiredDescription
fieldslist[DynamicField]-TrueList of dynamic fields.
sortUnion[bool, SortOrder]FalseFalseSorting option for the fields.

Query Stage Intermediate Parameters

This stage does not require intermediate parameters since it takes the information it needs from the final using the search stage name.

Example Configuration

_dynamic_results = DynamicResultsStage(
    engine_name=DEFAULT_ENGINE_NAME,
    enable=True,
    name='hits',
    title=UrlField(field='title', link='url'),
    sub_title=TextField(field='url'),
    thumbnail=None,
    non_displayed_fields=[],
	ignore_blanks=False,
    body=[
        [BoolField(label='Adult', field='adult'),
         NumberField(label='Popularity', field='metadata.popularity', format='1.2')],
        [TextField(field='overview')],
        [TextField(label='Status', field='status'),
         DateField(label='Release Date', field='release_date', format='%Y-%m-%d')],
        [ThumbnailsField(field='metadata.cast[*].profile_path_w185', alt='metadata.cast[*].name',
                         detail='metadata.cast[*].name', full_size='metadata.cast[*].profile_path')]
    ],
    search_response=SEARCH_STAGE_NAME
)

Body as a Grid for UI

IMPORTANT: Each field placed in each dynamic field must be fetch in the Search, using any of our query stages (Execute Semantic Search, Execute Query) or a custom query stage for the project, and all those fields must be fetched in the "fetch_fields" configured on those stages.

The body works as a grid, meaning you can see it as a matrix where it is composed as a vector of vectors. Each sub vector of this body is a row in the grid and each element inside these sub vectors is a column for that row. For example

title=UrlField(field='title', link='url'),
sub_title=TextField(field='url'),
thumbnail=MimeField(field='poster_path_w185', map_file='config/stages/fields/mimetype/mime_maps.json'),
body=[
        [BoolField(label='Adult', field='adult'),
         NumberField(label='Popularity', field='metadata.popularity', format='1,.2')],
        [TextField(field='overview', use_ellipsis=True)],
        [TextField(label='Status', field='status'),
         DateTimeField(label='Release Date', field='release_date', format='%Y-%m-%d')],
        [ThumbnailsField(field='metadata.cast[*].profile_path_w185',
                         alt='metadata.cast[?profile_path_w185 != None].name',
                         detail='metadata.cast[?profile_path_w185 != None].name',
                         full_size='metadata.cast[*].profile_path')],
        [TableField(field='metadata', columns_path='keys(cast[0])', rows_path='cast[*].*', include_additional_cols=True,
                    columns_definition=[NumberField(field='id', label='Char Id', format='1.0'),
                                        TextField(field='name', label='Actor name'),
                                        TextField(field='character', label='Rol')])],
        [NestedField(field='metadata.cast', collapsed=False, label='Cast', label_field='name', nested_elements=False,
                     body=[NumberField(field='cast_id', label='Char Id', format='1.0'),
                           TextField(field='name', label='Actor name'),
                           TextField(field='character', label='Rol')])]
    ],

leads to our demo UI results so you can track it the following way:

As you can see, the title, the sub title and the thumbnail have their own fixed positions in the results hence they're separated from the body, but everything else in the result card can be tracked by the body elements as a grid. 

  • No labels