Skip to content

Commit

Permalink
Fix "list_analyzers" and "output_mapping"
Browse files Browse the repository at this point in the history
I think they've been broken since
b6e92d4, which changed schema to have
a single mapping. Presumably this was done as part of deprecating `doc._type`
  • Loading branch information
michaelkirk committed Jul 10, 2023
1 parent 1e3ecd6 commit d43c9f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ node scripts/update_settings.js # update index settings

#### output schema file

Use this script to pretty-print the whole schema file or a single mapping to stdout.
Use this script to pretty-print the schema's mappings to stdout.

```bash
node scripts/output_mapping.js
Expand Down
3 changes: 1 addition & 2 deletions scripts/list_analyzers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const _ = require('lodash')
const colors = require('colors')
const cli = require('./cli');
const config = require('pelias-config').generate();
const schema = require('../schema');
const DEFAULT_ANALYZER = 'standard';
const NOT_APPLICABLE_ANALYZER = 'n/a';
Expand Down Expand Up @@ -54,7 +53,7 @@ const error = function(vals) {
}

// parse mapping
const mapping = schema.mappings[config.schema.typeName];
const mapping = schema.mappings;
const dynamic = mapping.dynamic_templates.map(t => _.first(_.map(t, v => v)));

// process and single mapping property (recursively)
Expand Down
19 changes: 1 addition & 18 deletions scripts/output_mapping.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
var config = require('pelias-config').generate();
var es = require('elasticsearch');
var client = new es.Client(config.esclient);
var schema = require('../schema');

var _index = ( process.argv.length > 3 ) ? process.argv[3] : config.schema.indexName;
var _type = ( process.argv.length > 2 ) ? process.argv[2] : null; // get type from cli args

// print out mapping for just one type
if ( _type ) {
var mapping = schema.mappings[_type];
if( !mapping ){
console.error( 'could not find a mapping in the schema file for', _index+'/'+_type );
process.exit(1);
}
console.log( JSON.stringify( mapping, null, 2 ) );
//print out the entire schema mapping
} else {
console.log( JSON.stringify( schema, null, 2 ) );
}
console.log( JSON.stringify( schema.mappings, null, 2 ) );

0 comments on commit d43c9f0

Please sign in to comment.