Parameter | Type | Default | Required | Description |
---|---|---|---|---|
name | str | 'dynamic_results' | False | Name for this specific stage. Used on the intermediate and final parameters. |
for_clause | str | 'default' | False | For clause. |
title | Optional[DynamicField] | - | False | Title information. |
sub_title | Optional[DynamicField] | - | False | Subtitle information. |
thumbnail | Optional[Union[ImageField]] | - | False | Thumbnail information. |
header | Optional[list[list[DynamicField]]] | [] | False | Header information as a grid (list of lists). |
body | Optional[list[list[DynamicField]]] | [] | False | Body information as a grid (list of lists). |
metadata | Optional[SectionFormat] | - | False | Metadata information. |
search_response | str | - | True | Name of the key in the final result in which query results will be stored. |
non_displayed_fields | Optional[list[NonDisplayField]] | - | False | List of fields to add as part of the UI response. |
ignore_blanks | Optional[bool] | False | False | Flag to ignore warnings when some dynamic values are None. (version 3.0.0^) |
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
field | str | - | True | Field name or path to the field from which to fetch the data. |
alias | Optional[str] | - | False | Alias to assign to the fetched values. If not specified, the field or path will be used as the name. |
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
fields | list[DynamicField] | - | True | List of dynamic fields. |
sort | Union[bool, SortOrder] | False | False | Sorting option for the fields. |
This stage does not require intermediate parameters since it takes the information it needs from the final using the search stage name.
Code Block | ||||
---|---|---|---|---|
| ||||
_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
) |
Warning |
---|
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
Code Block | ||||
---|---|---|---|---|
| ||||
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.