Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ Print a list of which plugins are installed and how to install any that are miss
node scripts/check_plugins.js
```

#### check indexed documents

Display a summary of doc counts per source/layer. By default the stats for the importing index is used. Only use `--api` if your requesting index differs from your importing index

```bash
node scripts/check_stats.js
node scripts/check_stats.js --api
```

## Configuration

### Settings from `pelias.json`
Expand Down
50 changes: 50 additions & 0 deletions scripts/check_stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const config = require('pelias-config').generate();
const es = require('elasticsearch');
const client = new es.Client(config.esclient);
const targetIndex = getTargetIndex();


async function stats(targetIndex) {
try {
const response = await client.search({
index: targetIndex,
body: {
aggs: {
sources: {
terms: {
field: 'source',
size: 100
},
aggs: {
layers: {
terms: {
field: "layer",
size: 100
}
}
}
}
},
size: 0,
},
timeout: '10s',
request_cache: true,
maxRetries: 1,
});
console.log("Results for index \"" + targetIndex + "\":")
console.log(JSON.stringify(response, null, 2));
process.exit(0);
}
catch (err) {
console.error(err);
process.exit(!!err);
}
};

function getTargetIndex() {
if (process.argv.length > 2 && ['--api', '-a'].indexOf(process.argv[2]) > -1) {
return config.api.indexName; //If none is set the value from pelias/config/config/defaults.json will be used ('pelias')
}
return config.schema.indexName;
}
stats(targetIndex);