From e3abaae479189f9f8224d57fbe1dc544e9a75feb Mon Sep 17 00:00:00 2001 From: missinglink Date: Wed, 13 Oct 2021 13:41:41 +0200 Subject: [PATCH] feat(concordance): add dedicated concordance field --- mappings/document.js | 9 +++++++++ test/compile.js | 15 +++++++++++++-- test/document.js | 2 +- test/fixtures/expected.json | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/mappings/document.js b/mappings/document.js index da22b396..5ac694c5 100644 --- a/mappings/document.js +++ b/mappings/document.js @@ -171,6 +171,9 @@ var schema = { population: multiplier, popularity: multiplier, + // concordance (indexed foreign key references) + concordance: hash, + // addendum (non-indexed supplimentary data) addendum: hash }, @@ -196,6 +199,12 @@ var schema = { similarity: 'peliasDefaultSimilarity' } } + },{ + concordance: { + path_match: 'concordance.*', + match_mapping_type: 'string', + mapping: keyword + } },{ addendum: { path_match: 'addendum.*', diff --git a/test/compile.js b/test/compile.js index 719dde7a..dfd323e0 100644 --- a/test/compile.js +++ b/test/compile.js @@ -61,9 +61,20 @@ module.exports.tests.dynamic_templates = function(test, common) { }); t.end(); }); + test('dynamic_templates: concordance', function (t) { + t.equal(typeof schema.mappings.dynamic_templates[2].concordance, 'object', 'concordance template specified'); + var template = schema.mappings.dynamic_templates[2].concordance; + t.equal(template.path_match, 'concordance.*'); + t.equal(template.match_mapping_type, 'string'); + t.deepEqual(template.mapping, { + type: 'keyword', + doc_values: false + }); + t.end(); + }); test('dynamic_templates: addendum', function (t) { - t.equal(typeof schema.mappings.dynamic_templates[2].addendum, 'object', 'addendum template specified'); - var template = schema.mappings.dynamic_templates[2].addendum; + t.equal(typeof schema.mappings.dynamic_templates[3].addendum, 'object', 'addendum template specified'); + var template = schema.mappings.dynamic_templates[3].addendum; t.equal(template.path_match, 'addendum.*'); t.equal(template.match_mapping_type, 'string'); t.deepEqual(template.mapping, { diff --git a/test/document.js b/test/document.js index 81aed4aa..0ce74fc7 100644 --- a/test/document.js +++ b/test/document.js @@ -23,7 +23,7 @@ module.exports.tests.properties = function(test, common) { module.exports.tests.fields = function(test, common) { var fields = ['source', 'layer', 'name', 'phrase', 'address_parts', 'parent', 'center_point', 'shape', 'bounding_box', 'source_id', 'category', - 'population', 'popularity', 'addendum']; + 'population', 'popularity', 'concordance', 'addendum']; test('fields specified', function(t) { t.deepEqual(Object.keys(schema.properties), fields); t.end(); diff --git a/test/fixtures/expected.json b/test/fixtures/expected.json index 6e58831e..4fae1049 100644 --- a/test/fixtures/expected.json +++ b/test/fixtures/expected.json @@ -2992,6 +2992,10 @@ "type": "keyword", "doc_values": false }, + "concordance": { + "type": "object", + "dynamic": true + }, "population": { "type": "long", "null_value": 0 @@ -3030,6 +3034,16 @@ } } }, + { + "concordance": { + "path_match": "concordance.*", + "match_mapping_type": "string", + "mapping": { + "type": "keyword", + "doc_values": false + } + } + }, { "addendum": { "path_match": "addendum.*",