Id Lookup
Sometimes it is neccessary to resolve some entities by id at query time. To use this feature you need admin access to the qsc plattform, because you need to change the search pipeline. Ask you administrator for more details.
Configurations
For the id lookup some complex configurations have to be done.
parameters | example | description |
---|---|---|
ParallelFilter.id | parallelIdLookupFilterTags | A unique id for the parallel filter. Pattern parallelIdLookupFilter$Entity |
ParallelFilter.pipelines.id | tagLookupPipeline | A unique id for the lookup pipeline filter. |
ElasticFilter.baseUrl | {{ searchIndexUrl }}/{{ env }}.{{ tenant }}.tags | The elasticsearch base url |
ElasticFilter.resultSetId | lookupTags | The result set id where the looked up entites are stored in the pipeline container. Pattern: lookup$Entity |
ElasticFilter.queryTransformer.profile | deprecated | deprecated |
ElasticFilter.queryTransformer.searchResultId | {{searchCode}} | The result set from where the ids must be extracted |
ElasticFilter.queryTransformer.idFields | sport_type_tag_id | A list of field ids from where the ids for the lookup are extracted. |
ElasticFilter.searchResultTransformer.fieldMapping | - | Mapping which defines the rquired fields of the entity to display. |
QscIdLookupMergingFilter.id | qscIdLookupMergingFilterTags | A unique id. Pattern: qscIdLookupMergingFilter$Entity |
QscIdLookupMergingFilter.resultSetId | {{searchCode}} | The id of the result set to which the entities must be merged. |
QscIdLookupMergingFilter.lookupResultSetId | lookupTags | The id of the result set where the entities for merging are available. |
QscIdLookupMergingFilter.idMappings | sport_type_tag_id->sport_type_tag | A mapping from the id to mapped, to id of the field where the mapped entity is stored. |
- !!com.quasiris.qsf.pipeline.filter.ParallelFilter
active: true
id: parallelIdLookupFilterTags
pipelines:
- filterList:
- !!com.quasiris.qsf.pipeline.filter.elastic.ElasticFilter
active: true
baseUrl: "{{ searchIndexUrl }}/{{ env }}.{{ tenant }}.tags"
id: idLookupElasticFilterTags
resultSetId: lookupTags
queryTransformer: !!com.quasiris.qsc.search.service.idlookup.QscIdLookupQueryTransformer
profile: DEPRECATED
searchResultId: {{searchCode}}
idFields:
- sport_type_tag_id
searchResultTransformer: !!com.quasiris.qsf.pipeline.filter.elastic.Elastic2SearchResultMappingTransformer
fieldMapping:
name:
- name
id:
- id
category:
- category
slug:
- slug
- !!com.quasiris.qsc.search.service.idlookup.QscIdLookupMergingFilter
active: true
id: qscIdLookupMergingFilterTags
resultSetId: {{searchCode}}
lookupResultSetId: lookupTags
idMappings:
- sport_type_tag_id->sport_type_tag
id: tagLookupPipeline
How it works
- at first a search result is retrieved
- the QscIdLookupQueryTransformer extract the ids from the configured
idField: ["sport_type_tag_id"]
in the retrieved search result - the values for the extracted ids are retrieved by a elastic search query
- the index is configured in the baseUrl:
{{ searchIndexUrl }}/{{ env }}.{{ tenant }}.tags
{
"result": {
"profiles": {
"documents": [
{
"document": {
"sport_type_tag_id": "9361f47f-2998-4b31-ada9-bf9a3b9dac06",
"name": "A basketball profile"
}
}
]
}
}
}
- the QscIdLookupMergingFilter merges the retrieved entites from the
lookupResultSetId: lookupTags
to theresultSetId: {{searchCode}}
- the sourceId and the target field name are configured in the ``idMappings: sport_type_tag_id->sport_type_tag`
- the Elastic2SearchResultMappingTransformer map the necessary fields of the entity
fieldMapping:
name:
- name
id:
- id
category:
- category
slug:
- slug
{
"result": {
"profiles": {
"documents": [
{
"document": {
"sport_type_tag_id": "9361f47f-2998-4b31-ada9-bf9a3b9dac06",
"sport_type_tag": {
"name": "Handball",
"id": "9361f47f-2998-4b31-ada9-bf9a3b9dac06",
"category": "SPORT_TYPE",
"slug": "handball"
},
"name": "A handball profile"
}
}
]
}
}
}
- the filter must be wrapped by a ParallelFilter because QscIdLookupQueryTransformer will stop the pipeline in case no ids were found to resolve