Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Filters are not working with Special Charactors #139

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/buildFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function buildFilter(modelName, idName, criteria = {}, size = null, offset = nul
},
filter: [{
term: {
docType: modelName
'docType.keyword': modelName
}
}]
}
Expand Down
4 changes: 2 additions & 2 deletions lib/buildNestedQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function buildNestedQueries(body, model, idName, where, nestedFields) {
},
filter: [{
term: {
docType: model
'docType.keyword': model
}
}]
}
Expand All @@ -37,7 +37,7 @@ function buildNestedQueries(body, model, idName, where, nestedFields) {
addedDocTypeToRootPath = true;
rootPath.bool.filter.push({
term: {
docType: model
'docType.keyword': model
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/buildWhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function buildWhere(model, idName, where) {
},
filter: [{
term: {
docType: model
'docType.keyword': model
}
}]
}
Expand Down
22 changes: 11 additions & 11 deletions test/es-v6/01.filters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}]
}
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('Connector', function() {
bool: {
must: [{
match: {
docType: modelName
'doctype.keyword': modelName
}
}, {
bool: {
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('Connector', function() {
bool: {
must: [{
match: {
docType: modelName
'doctype.keyword': modelName
}
}, {
bool: {
Expand Down Expand Up @@ -519,7 +519,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -575,7 +575,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}]
}
Expand Down Expand Up @@ -636,7 +636,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -693,7 +693,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -766,7 +766,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down
22 changes: 11 additions & 11 deletions test/es-v7/01.filters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}]
}
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -290,7 +290,7 @@ describe('Connector', function() {
bool: {
must: [{
match: {
docType: modelName
'doctype.keyword': modelName
}
}, {
bool: {
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -440,7 +440,7 @@ describe('Connector', function() {
bool: {
must: [{
match: {
docType: modelName
'doctype.keyword': modelName
}
}, {
bool: {
Expand Down Expand Up @@ -519,7 +519,7 @@ describe('Connector', function() {
},
{
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -575,7 +575,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}]
}
Expand Down Expand Up @@ -636,7 +636,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -693,7 +693,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down Expand Up @@ -766,7 +766,7 @@ describe('Connector', function() {
}
}, {
match: {
docType: modelName
'doctype.keyword': modelName
}
}
]
Expand Down