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

**URL:** <https://discuss.elastic.co/t/dec-24th-2022-en-define-your-own-facets-for-custom-sources-in-workplace-search/318640>\
**Category:** Advent Calendar\
**Created:** [December 24, 2022, 8:00am UTC](https://discuss.elastic.co/t/dec-24th-2022-en-define-your-own-facets-for-custom-sources-in-workplace-search/318640 "2022-12-24T08:00:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 24, 2022, 8:00am UTC](https://discuss.elastic.co/t/dec-24th-2022-en-define-your-own-facets-for-custom-sources-in-workplace-search/318640/1 "2022-12-24T08:00:55Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/818d8394376817d1c96c61c72ef059a1fe26594a.jpeg)

Cet article est aussi disponible [en français](https://discuss.elastic.co/t/318641).

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:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/1/f1b8021e05cd4f28f3cd6e108bdce8e2f796e9af.jpeg)

# The Custom Source API

Two years ago, I explained [how to use the Custom Source API](https://discuss.elastic.co/t/254740) 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](https://fscrawler.readthedocs.io/) as a provider gives the following facets:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d1b66b849b52050e1312b6fd652519ccf6e4e787.png)

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](https://github.com/dadoonet/fscrawler/blob/9b2ea54c4cf74bf9875815a32f06dac0e5094ce4/settings/src/main/resources/fr/pilato/elasticsearch/crawler/fs/_default/8/_wpsearch_settings.json#L77-L106):

```auto
"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.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/9/9938867ec5d29143c2a8bc8c555a3b6a9fe703b1.png)

**Pro tip:** if you use the same facet names and field names as [the Workplace Search standard sources](https://www.elastic.co/guide/en/workplace-search/8.5/workplace-search-custom-api-sources.html#custom-api-source-recommended-field-names), 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](https://www.elastic.co/guide/en/workplace-search/8.5/workplace-search-customizing-filters.html#enabling-faceted-fields)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 21, 2023, 8:01am UTC](https://discuss.elastic.co/t/dec-24th-2022-en-define-your-own-facets-for-custom-sources-in-workplace-search/318640/2 "2023-01-21T08:01:36Z")

</div>

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