diff --git a/README.md b/README.md index 044daf6..03407b3 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ npm install loopback-connector-esv6 --save --save-exact - **This connector will only connect to one index per datasource.** - This package is created to support ElasticSearch v6.x and 7.x only. -- `docType` property is automatically added in mapping properties which is required to differentiate documents stored in index with loopback model data. It stores loopback modelName value. `docType: { type: "keyword", index: true }` +- `docType` property is automatically added in mapping properties which is required to differentiate documents stored in index with loopback model data. It stores loopback modelName value. `'doctype.keyword': { type: "keyword", index: true }` ### Required diff --git a/lib/buildFilter.js b/lib/buildFilter.js index fb8f29f..f0b9176 100644 --- a/lib/buildFilter.js +++ b/lib/buildFilter.js @@ -76,7 +76,7 @@ function buildFilter(modelName, idName, criteria = {}, size = null, offset = nul }, filter: [{ term: { - docType: modelName + 'docType.keyword': modelName } }] } diff --git a/lib/buildNestedQueries.js b/lib/buildNestedQueries.js index 881607b..ede19ea 100644 --- a/lib/buildNestedQueries.js +++ b/lib/buildNestedQueries.js @@ -16,7 +16,7 @@ function buildNestedQueries(body, model, idName, where, nestedFields) { }, filter: [{ term: { - docType: model + 'docType.keyword': model } }] } @@ -37,7 +37,7 @@ function buildNestedQueries(body, model, idName, where, nestedFields) { addedDocTypeToRootPath = true; rootPath.bool.filter.push({ term: { - docType: model + 'docType.keyword': model } }); } diff --git a/lib/buildWhere.js b/lib/buildWhere.js index 16609e3..4ac5cc7 100644 --- a/lib/buildWhere.js +++ b/lib/buildWhere.js @@ -48,7 +48,7 @@ function buildWhere(model, idName, where) { }, filter: [{ term: { - docType: model + 'docType.keyword': model } }] } diff --git a/test/es-v6/01.filters.test.js b/test/es-v6/01.filters.test.js index d13dfbc..10d2938 100644 --- a/test/es-v6/01.filters.test.js +++ b/test/es-v6/01.filters.test.js @@ -65,7 +65,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } }] } @@ -175,7 +175,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -240,7 +240,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -290,7 +290,7 @@ describe('Connector', function() { bool: { must: [{ match: { - docType: modelName + 'doctype.keyword': modelName } }, { bool: { @@ -391,7 +391,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -440,7 +440,7 @@ describe('Connector', function() { bool: { must: [{ match: { - docType: modelName + 'doctype.keyword': modelName } }, { bool: { @@ -519,7 +519,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -575,7 +575,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } }] } @@ -636,7 +636,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -693,7 +693,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -766,7 +766,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] diff --git a/test/es-v7/01.filters.test.js b/test/es-v7/01.filters.test.js index d13dfbc..10d2938 100644 --- a/test/es-v7/01.filters.test.js +++ b/test/es-v7/01.filters.test.js @@ -65,7 +65,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } }] } @@ -175,7 +175,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -240,7 +240,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -290,7 +290,7 @@ describe('Connector', function() { bool: { must: [{ match: { - docType: modelName + 'doctype.keyword': modelName } }, { bool: { @@ -391,7 +391,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -440,7 +440,7 @@ describe('Connector', function() { bool: { must: [{ match: { - docType: modelName + 'doctype.keyword': modelName } }, { bool: { @@ -519,7 +519,7 @@ describe('Connector', function() { }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -575,7 +575,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } }] } @@ -636,7 +636,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -693,7 +693,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ] @@ -766,7 +766,7 @@ describe('Connector', function() { } }, { match: { - docType: modelName + 'doctype.keyword': modelName } } ]