Dec 24th, 2022: [EN] Define your own facets for Custom Sources in Workplace Search

Cet article est aussi disponible en français.

Workplace Search provides a very nice and easy way to search within all the documents you have within your company/entity.

You can get content from various sources, like Github, Dropbox, Box, Google Drive...

Cool, right?

Faceted navigation for default sources

The standard sources come with a default set of fields for faceted navigation. For example, when you select a GitHub source, it comes with:

The Custom Source API

Two years ago, I explained how to use the Custom Source API to add your own source to Workplace Search.

But the default behavior for faceted navigation might not fit your business needs. For example, with Elastic 8.5.0, the default behavior when using FSCrawler as a provider gives the following facets:

You can see the facets panel on the left is pretty much empty, although by default FSCrawler generates the following fields:

"body": "text",
"comments": "text",
"tags": "text",
"title": "text",
"type": "text",
"url": "text",
"extension": "text",
"mime_type": "text",
"path": "text",
"size": "number",
"created_by": "text",
"name": "text",
"language": "text",
"text_size": "number",
"created_at": "date",
"last_modified": "date"

Implementing our own facets

To add your own facets, you need to define them when you create the Workplace Search Schema using the facets.overrides array. Simply provide an object for each facet which contains:

  • display_name: the name of the facet you want to display
  • field: which field is used to compute the facet values and perform the filter on
  • enabled: must be true if you want to enable faceted navigation

For example, in FSCrawler, we defined the following facets:

"facets": {
  "overrides": [
    { "display_name": "Media Type", "field": "mime_type", "enabled": true },
    { "display_name": "Extension", "field": "extension", "enabled": true },
    { "display_name": "Tags", "field": "tags", "enabled": true },
    { "display_name": "Created By", "field": "created_by", "enabled": true },
    { "display_name": "Language", "field": "language", "enabled": true }
  ]
}

When you revisit the search interface, you can now see the facets in action.

Pro tip: if you use the same facet names and field names as the Workplace Search standard sources, you will be able to display facets and use filters on all sources at the same time.

Documentation: Customizing content source filters | Workplace Search Guide [8.5] | Elastic

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.