Merge pull request #11962 from backstage/emmaindal/elasticsearch-search-engine-custom-index-template

[Search - ES module] possibility to set custom index template
This commit is contained in:
Emma Indal
2022-06-10 14:32:29 +02:00
committed by GitHub
7 changed files with 125 additions and 0 deletions
+25
View File
@@ -102,6 +102,31 @@ import { Client } from '@elastic/elastic-search';
const client = searchEngine.newClient(options => new Client(options));
```
#### Set custom index template
The elasticsearch engine gives you the ability to set a custom index template if needed.
> Index templates define settings, mappings, and aliases that can be applied automatically to new indices.
```typescript
// app/backend/src/plugins/search.ts
const searchEngine = await ElasticSearchSearchEngine.initialize({
logger: env.logger,
config: env.config,
});
searchEngine.setIndexTemplate({
name: '<name-of-your-custom-template>',
body: {
index_patterns: ['<your-index-pattern>'],
template: {
mappings: {},
settings: {},
},
},
});
```
## Example configurations
### AWS