Skip to content

Commit

Permalink
feat(schema): Use a single Elasticsearch mapping type
Browse files Browse the repository at this point in the history
Currently, we define a unique Elasticsearch mapping type for each layer.
There are 20 different layers in our standard datsets now, but all the
mapping types are identical.

This currently is non-optimal, but not really a big deal. However, in
Elasticsearch 6, multiple mapping types are no longer supported. So we
might as well get ahead of things now and do it.

One immediate benefit, this change removes 4370 duplicate mapping type
definition lines from the expected schema fixture. The time saved in
updating that file alone when we make future changes will be huge! :)

Connects pelias/pelias#719
  • Loading branch information
orangejulius committed Sep 13, 2019
1 parent 11b4599 commit 4d36398
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 7,367 deletions.
32 changes: 16 additions & 16 deletions integration/address_matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports.tests.functional = function(test, common){
// index some docs
suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '1', body: { address_parts: {
name: 'Mapzen HQ',
number: 30,
Expand All @@ -28,7 +28,7 @@ module.exports.tests.functional = function(test, common){

suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '2', body: { address_parts: {
name: 'Fake Venue',
number: 300,
Expand All @@ -40,7 +40,7 @@ module.exports.tests.functional = function(test, common){

suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '3', body: { address_parts: {
name: 'Mock British Address',
number: 3000,
Expand All @@ -52,7 +52,7 @@ module.exports.tests.functional = function(test, common){

suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '4', body: { address_parts: {
name: 'Mystery Location',
number: 300,
Expand All @@ -66,7 +66,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.number': 30 } }
]}}}
Expand All @@ -81,7 +81,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match_phrase: { 'address_parts.street': 'west 26th street' } }
]}}}
Expand All @@ -96,7 +96,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match_phrase: { 'address_parts.street': 'W 26th ST' } }
]}}}
Expand All @@ -111,7 +111,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': '10010' } }
]}}}
Expand All @@ -126,7 +126,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': 'e24dn' } }
]}}}
Expand All @@ -141,7 +141,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': '100-10' } }
]}}}
Expand All @@ -156,7 +156,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': '10 0 10' } }
]}}}
Expand All @@ -171,7 +171,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': 'E2-4DN' } }
]}}}
Expand All @@ -186,7 +186,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { bool: { must: [
{ match: { 'address_parts.zip': 'E2 4DN' } }
]}}}
Expand Down Expand Up @@ -220,7 +220,7 @@ module.exports.tests.venue_vs_address = function(test, common){
// index a venue
suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '1', body: {
name: { default: 'Union Square' },
phrase: { default: 'Union Square' }
Expand All @@ -234,7 +234,7 @@ module.exports.tests.venue_vs_address = function(test, common){
return function( done ){
let id = i + 100; // id offset
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: String(id),
body: {
name: { default: `${id} Union Square` },
Expand All @@ -258,7 +258,7 @@ module.exports.tests.venue_vs_address = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
searchType: 'dfs_query_then_fetch',
size: TOTAL_ADDRESS_DOCS+1,
body: {
Expand Down
8 changes: 4 additions & 4 deletions integration/admin_matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports.tests.functional = function(test, common){
// index a document with all admin values
suite.action( function( done ){
suite.client.index({
index: suite.props.index, type: 'test',
index: suite.props.index, type: 'doc',
id: '1', body: {
parent: {
country: 'Test Country',
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: { 'parent.country': 'Test Country' } } }
}, function( err, res ){
t.equal( err, undefined );
Expand All @@ -59,7 +59,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: { 'parent.country_a': 'TestCountry' } } }
}, function( err, res ){
t.equal( err, undefined );
Expand All @@ -72,7 +72,7 @@ module.exports.tests.functional = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: { 'parent.country_id': '100' } } }
}, function( err, res ){
t.equal( err, undefined );
Expand Down
14 changes: 7 additions & 7 deletions integration/analyzer_peliasPhrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports.tests.slop_query = function(test, common){
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'mytype',
type: 'doc',
id: '1',
body: { name: { default: 'Lake Cayuga' }, phrase: { default: 'Lake Cayuga' } }
}, done );
Expand All @@ -165,7 +165,7 @@ module.exports.tests.slop_query = function(test, common){
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'mytype',
type: 'doc',
id: '2',
body: { name: { default: 'Cayuga Lake' }, phrase: { default: 'Cayuga Lake' } }
}, done );
Expand All @@ -175,7 +175,7 @@ module.exports.tests.slop_query = function(test, common){
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'mytype',
type: 'doc',
id: '3',
body: { name: { default: '7991 Lake Cayuga Dr' }, phrase: { default: '7991 Lake Cayuga Dr' } }
}, done );
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports.tests.slop_query = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'mytype',
type: 'doc',
searchType: 'dfs_query_then_fetch',
body: buildQuery('Lake Cayuga')
}, function( err, res ){
Expand Down Expand Up @@ -251,7 +251,7 @@ module.exports.tests.slop = function(test, common){
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'test',
type: 'doc',
id: '1',
body: { name: { default: '52 Görlitzer Straße' } }
}, done);
Expand All @@ -264,7 +264,7 @@ module.exports.tests.slop = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
searchType: 'dfs_query_then_fetch',
body: { query: { match: {
'name.default': {
Expand Down Expand Up @@ -326,4 +326,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};
4 changes: 2 additions & 2 deletions integration/analyzer_peliasQueryFullToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports.tests.slop = function(test, common){
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'test',
type: 'doc',
id: '1',
body: { name: { default: '52 Görlitzer Straße' } }
}, done);
Expand All @@ -156,7 +156,7 @@ module.exports.tests.slop = function(test, common){
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: {
'name.default': {
'analyzer': 'peliasQueryFullToken',
Expand Down
12 changes: 6 additions & 6 deletions integration/autocomplete_abbreviated_street_names.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
suite.action( function( done ){
suite.client.index({
index: suite.props.index,
type: 'test',
type: 'doc',
id: '1',
body: { name: { default: 'Grolmanstraße' } }
}, done);
Expand All @@ -32,7 +32,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
Expand All @@ -50,7 +50,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
suite.assert( function( done ){
suite.client.search({
index: suite.props.index,
type: 'test',
type: 'doc',
body: { query: { match: {
'name.default': {
'analyzer': 'peliasQueryFullToken',
Expand Down Expand Up @@ -81,7 +81,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
// suite.action( function( done ){
// suite.client.index({
// index: suite.props.index,
// type: 'test',
// type: 'doc',
// id: '1',
// body: { name: { default: 'Grolmanstr.' } }
// }, done);
Expand All @@ -94,7 +94,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
// suite.assert( function( done ){
// suite.client.search({
// index: suite.props.index,
// type: 'test',
// type: 'doc',
// body: { query: { match: {
// 'name.default': {
// 'analyzer': 'peliasQueryPartialToken',
Expand All @@ -115,7 +115,7 @@ module.exports.tests.index_expanded_form_search_contracted = function(test, comm
// suite.assert( function( done ){
// suite.client.search({
// index: suite.props.index,
// type: 'test',
// type: 'doc',
// body: { query: { match: {
// 'name.default': {
// 'analyzer': 'peliasQueryFullToken',
Expand Down
Loading

0 comments on commit 4d36398

Please sign in to comment.