Skip to content

Commit

Permalink
[Discover] Always request unmapped fields in a single doc view and a …
Browse files Browse the repository at this point in the history
…context view (#91825)

* [Discover] Always request unmapped fields in a single doc view

* Updating unit test

* Request unmapped fields in context view
  • Loading branch information
Maja Grubic authored Feb 18, 2021
1 parent 759f343 commit c5dabc2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function fetchAnchorProvider(indexPatterns, searchSource, useNewFieldsApi
.setField('sort', sort);
if (useNewFieldsApi) {
searchSource.removeField('fieldsFromSource');
searchSource.setField('fields', ['*']);
searchSource.setField('fields', [{ field: '*', include_unmapped: 'true' }]);
}
const response = await searchSource.fetch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('context app', function () {
const removeFieldsSpy = searchSourceStub.removeField.withArgs('fieldsFromSource');
expect(setFieldsSpy.calledOnce).toBe(true);
expect(removeFieldsSpy.calledOnce).toBe(true);
expect(setFieldsSpy.firstCall.args[1]).toEqual(['*']);
expect(setFieldsSpy.firstCall.args[1]).toEqual([{ field: '*', include_unmapped: 'true' }]);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function fetchContextProvider(indexPatterns: IndexPatternsContract, useNewFields
const searchSource = await data.search.searchSource.create();
if (useNewFieldsApi) {
searchSource.removeField('fieldsFromSource');
searchSource.setField('fields', ['*']);
searchSource.setField('fields', [{ field: '*', include_unmapped: 'true' }]);
}
return searchSource
.setParent(undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ describe('Test of <Doc /> helper / hook', () => {
"_source": false,
"docvalue_fields": Array [],
"fields": Array [
"*",
Object {
"field": "*",
"include_unmapped": "true",
},
],
"query": Object {
"ids": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function buildSearchBody(
},
stored_fields: computedFields.storedFields,
_source: !useNewFieldsApi,
fields: useNewFieldsApi ? ['*'] : undefined,
fields: useNewFieldsApi ? [{ field: '*', include_unmapped: 'true' }] : undefined,
script_fields: computedFields.scriptFields,
docvalue_fields: computedFields.docvalueFields,
};
Expand Down

0 comments on commit c5dabc2

Please sign in to comment.