Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
12 changes: 8 additions & 4 deletions src/server/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,21 @@ class ES {
if (typeof size !== 'undefined') {
queryBody.size = size;
}
if (fields) {
const esFields = fromFieldsToSource(fields);
if (esFields.length > 0) queryBody._source = esFields;
if (fields !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't do a single if (typeof fields !== 'undefined') and set queryBody._source = false; in its else clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'll break the backward compatibility, in case there is code that doesn't define fields, but still uses _source for something.

if (fields) {
const esFields = fromFieldsToSource(fields);
if (esFields.length > 0) queryBody._source = esFields;
} else {
queryBody._source = false;
}
}
return this.query(esIndex, esType, queryBody);
}

async getCount(esIndex, esType, filter) {
const result = await this.filterData(
{ esInstance: this, esIndex, esType },
{ filter },
{ filter, fields: false },
);
return result.hits.total;
}
Expand Down