Another example

Another example

For the purpose of this example let's say we have an activity-logs index in Elasticsearch with the following mapping.

{
  "mappings": {
    "_doc": {
      "dynamic": "strict",
      "properties": {
        "action": {
          "type": "keyword"
        },
        "label": {
          "type": "text",
          "index_options": "docs",
          "norms": false
        },
        "userId": {
          "type": "keyword"
        },
        "collectionId": {
          "type": "keyword"
        },
        "createdAt": {
          "type": "date"
        }
      }
    }
  }
}

First, we declare the activity-logs collection in the forest/ directory.

In this Smart Collection, we want to display for each activity log its action, the label (in a field description), the related user that made the activity, the collectionId on which the activity was made and the date the activity was made by the user.

You can check out the list of available field options if you need them for your own case.

This is a complex use case: How to handle filters on related data. We want to be able to filter using the user.mail field. To accommodate you we already provide you a simple service ElasticsearchHelper that handles all the logic to connect with your Elasticsearch data.

Another way to search through related data is to implement your own search logic.

Last updated

Was this helpful?