Skip to content

Commit

Permalink
new option 'query'.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 4, 2023
1 parent 0b951e1 commit 45f91db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -115,6 +115,7 @@ transformer({
- `targetIndexName`: The target Elasticsearch index where documents will be indexed.
- `mappings`: Optional Elasticsearch document mappings. If not set and you're reindexing from another index, the mappings from the existing index will be used.
- `mappingsOverride`: If you're reindexing and this is set to `true`, `mappings` will be applied on top of the source index's mappings. Defaults to `false`.
- `query`: Optional Elasticsearch [DSL query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to filter documents from the source index.
- `skipHeader`: If true, skips the first line of the source file. Defaults to `false`.
- `transform(line)`: A callback function which allows the transformation of a source line into one or several documents.
- `verbose`: Logging verbosity, defaults to `true`
Expand Down
3 changes: 2 additions & 1 deletion src/_index-reader.js
Expand Up @@ -5,7 +5,7 @@ const MAX_QUEUE_SIZE = 5;
// create a new progress bar instance and use shades_classic theme
const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);

export default function indexReaderFactory(indexer, sourceIndexName, transform, client) {
export default function indexReaderFactory(indexer, sourceIndexName, transform, client, query) {
return async function indexReader() {
const responseQueue = [];
let docsNum = 0;
Expand All @@ -15,6 +15,7 @@ export default function indexReaderFactory(indexer, sourceIndexName, transform,
index: sourceIndexName,
scroll: '30s',
size: 10000,
query,
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Expand Up @@ -16,6 +16,7 @@ export default async function transformer({
targetIndexName,
mappings,
mappingsOverride = false,
query,
skipHeader = false,
transform,
verbose = true,
Expand Down Expand Up @@ -83,6 +84,7 @@ export default async function transformer({
sourceIndexName,
transform,
sourceClient,
query,
);
}

Expand Down

0 comments on commit 45f91db

Please sign in to comment.