Use aggregated tags to combine attributes from multiple entities into one index document

Configure tags through aggregation when you have relational data, and you want to combine information from multiple content items into a new attribute.

Note

If you need a simple tag configuration where you only assign a tag to one or more entities, use basic tags. With basic tags, Search does not evaluate and match based on shared attributes.

When you configure tags through aggregations, you define a mapping between attributes for Search to evaluate and match. You also specify which attributes you want to include in an index document upon a successful match.

Note

This topic describes how to create a tag when there is a relationship between attributes in different entities, that is, when you need flat aggregation. To define a relationship between attributes in the same entity, define tags through hierarchical aggregation. To do this, follow the same process configuring a tag through flat aggregation, but ensure that you accurately define fields within the same entity.

This topic shows you how to create a tag through flat aggregation in the following scenario:

  • You have a website that has information about actors and movies.

  • Your implementation has the Actor and Movie entities.

    • The Actor entity has the following attributes:

      • actor_id

      • actor_name.

      • actor_description

      • actor_age

      • actor_gender

    • The Movie entity has the following attributes:

      • movie_id

      • movie_name

      • movie_genre

      • movie_year

      • movie_cast

      • movie_director

      • movie_awards

  • You want to configure this search experience: when an actor appears as a search result, show a list of movies they acted in.

To support this experience, you'll need index documents that have Actor attributes as well as an attribute that lists movies they have acted in. To get this, you can create a tag through flat aggregation under the Actor entity and also associate it with the Movie entity. Then, use the actor's name as the common attribute between entities and map actors to movies.

Here's why you do this: While the Actor entity does not have movie information, the Movie entity has the actor information contained with the movie_cast attribute.

Notice

Before you configure a tag through aggregations:

  • Create a new attribute to hold the aggregated information. Ensure that the attribute is of the type array of objects and that it belongs to the same entity as the tag you're creating.

You'll need to do this for tags you create through flat or hierarchical aggregation.

In this example, you can create an attribute called filmography that belongs to the Actor entity.

To configure a tag through flat aggregations:

  1. On the menu bar, click Sources, and select the source you created. Then, on the Source Settings page, next to Document Extractors, click Edit.

  2. At the bottom of the Tags Definition page, click Add Tag .

  3. To associate the tag with an entity, in the Entity drop-down menu, click an entity.

    Note

    When you configure tags though aggregation, you can think of the Entity as the primary entity or parent entity for the tag.

    In this example, click the Actor entity.

  4. To specify that you want to configure tags through aggregation, in the From drop-down menu, click Aggregations. To configure the type of aggregation to use, in the Type drop-down menu, click the type of aggregation you need.

    In this example, click Flat.

  5. To name the tag, in the Source Tag field, enter a meaningful name that describes the purpose of the tag.

    Note

    Name the tag so that any user can understand the tag's purpose just by looking at its name. This is to avoid confusion because, in the document extractor, you select from a list of tag names and then configure extraction logic for that tag.

    In this example, enter actor with movies.

  6. Define the entity from which you want to borrow attributes. To do this, in the Foreign Tag field, enter the name of the entity.

    Note

    When you configure tags though aggregation, you can think of Foreign Tag as the foreign entity for the tag.

    In this example, enter Movie.

  7. Define which attribute in the parent entity (the Entity you defined in Step 2) you want to use as a baseline to check if a mapping is possible. To do this, in the Source Field field, enter the name of an attribute from the parent entity.

    In this example, enter actor_name.

  8. Define which attributes of the foreign entity you want to use as a comparison to check if a mapping is possible. To do this, in the Foreign Field field, enter the attribute name.

    In this example, enter movie_cast. You can do this because movie_cast is an array of strings, with each string being the name of an actor from this movie.

  9. Specify the attribute to combine and hold the content from the foreign entity. To do this, in the Target Tag field, enter the name of the attribute you configured in the prerequisite.

    In this example, enter filmography.

  10. Specify which attributes of the foreign entity you want to pull into the index document. To do this, in the Fields to Project field, enter attribute names from the foreign entity.

    After extraction, where mapping is successful, these attributes appear nested within the new array of objects attribute you specified in the Target Tag field.

    For example, enter movie_name, movie_year, and movie_genre.

  11. Click Save.

    Note

    Optionally, if you also want to include attributes from another entity in this index document, repeat Steps 2 through 9. Ensure that the tag name you enter in the Source Tags field is identical to the first tag you created. This is because you want to expand the scope of the existing tag, not define a new tag.

After you configure a tag, in the document extractor for the source, select the tag you created and extract attributes according to your use case.

Do you have some feedback for us?

If you have suggestions for improving this article,