Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Sep 4, 2024
1 parent f148c18 commit a0eb864
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
2 changes: 0 additions & 2 deletions lib/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,6 @@ function addDocumentsGetter(result) {
function appendFilterPath(filter, params, force) {
if (params.filter_path !== undefined) {
params.filter_path += ',' + filter;
} else if (params.filterPath !== undefined) {
params.filterPath += ',' + filter;
} else if (force === true) {
params.filter_path = filter;
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ test('Disable keep alive agent', (t) => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
node: `http://localhost:${port}`,
headers: { connection: 'close' },
agent: false,
});

Expand Down
33 changes: 1 addition & 32 deletions test/unit/helpers/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test('kGetHits fallback', async (t) => {
t.same(result, []);
});

test('Merge filter paths (snake_case)', async (t) => {
test('Merge filter paths', async (t) => {
const MockConnection = connection.buildMockConnection({
onRequest(params) {
t.equal(params.querystring, 'filter_path=foo%2Chits.hits._source');
Expand Down Expand Up @@ -112,34 +112,3 @@ test('Merge filter paths (snake_case)', async (t) => {
});
t.same(result, [{ one: 'one' }, { two: 'two' }, { three: 'three' }]);
});

test('Merge filter paths (camelCase)', async (t) => {
const MockConnection = connection.buildMockConnection({
onRequest(params) {
t.equal(params.querystring, 'filter_path=foo%2Chits.hits._source');
return {
body: {
hits: {
hits: [
{ _source: { one: 'one' } },
{ _source: { two: 'two' } },
{ _source: { three: 'three' } },
],
},
},
};
},
});

const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnection,
});

const result = await client.helpers.search({
index: 'test',
filterPath: 'foo',
body: { foo: 'bar' },
});
t.same(result, [{ one: 'one' }, { two: 'two' }, { three: 'three' }]);
});

0 comments on commit a0eb864

Please sign in to comment.