Set the default batchSize to 1000 for all search engines.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2022-04-29 17:26:02 +02:00
parent 0950038651
commit 71d3432710
5 changed files with 11 additions and 4 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/plugin-search-backend-node': patch
'@backstage/plugin-search-backend-module-elasticsearch': patch
'@backstage/plugin-search-backend-module-pg': patch
---
Search Engines will now index documents in batches of 1000 instead of 100 (under the hood). This may result in your Backstage backend consuming slightly more memory during index runs, but should dramatically improve indexing performance for large document sets.
@@ -53,7 +53,7 @@ export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer {
private bulkResult: Promise<any>;
constructor(options: ElasticSearchSearchEngineIndexerOptions) {
super({ batchSize: 100 });
super({ batchSize: 1000 });
this.logger = options.logger;
this.startTimestamp = process.hrtime();
this.type = options.type;
@@ -136,7 +136,7 @@ describe('PgSearchEngine', () => {
// Indexer instantiated with expected args.
expect(PgSearchEngineIndexer).toHaveBeenCalledWith(
expect.objectContaining({
batchSize: 100,
batchSize: 1000,
type: 'my-type',
databaseStore: database,
}),
@@ -78,7 +78,7 @@ export class PgSearchEngine implements SearchEngine {
async getIndexer(type: string) {
return new PgSearchEngineIndexer({
batchSize: 100,
batchSize: 1000,
type,
databaseStore: this.databaseStore,
});
@@ -27,7 +27,7 @@ export class LunrSearchEngineIndexer extends BatchSearchEngineIndexer {
private docStore: Record<string, IndexableDocument> = {};
constructor() {
super({ batchSize: 100 });
super({ batchSize: 1000 });
this.builder = new lunr.Builder();
this.builder.pipeline.add(lunr.trimmer, lunr.stopWordFilter, lunr.stemmer);