File tree Expand file tree Collapse file tree 2 files changed +60
-3
lines changed
src/plugins/data/common/search/search_source Expand file tree Collapse file tree 2 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,33 @@ describe('SearchSource', () => {
141141 ],
142142 }
143143 ` ) ;
144+
145+ // calling twice gives the same result: no searchSources in the hierarchy were modified
146+ expect ( searchSource . getFields ( RECURSE ) ) . toMatchInlineSnapshot ( `
147+ Object {
148+ "aggs": 5,
149+ "filter": Array [
150+ Object {
151+ "meta": Object {
152+ "alias": null,
153+ "disabled": false,
154+ "index": "d180cae0-60c3-11eb-8569-bd1f5ed24bc9",
155+ "negate": false,
156+ "params": Object {},
157+ },
158+ "query": Object {
159+ "range": Object {
160+ "@date": Object {
161+ "format": "strict_date_optional_time",
162+ "gte": "2016-01-27T18:11:05.010Z",
163+ "lte": "2021-01-27T18:11:05.010Z",
164+ },
165+ },
166+ },
167+ },
168+ ],
169+ }
170+ ` ) ;
144171 } ) ;
145172
146173 test ( 'recurses parents to get the entire filters: function filter' , ( ) => {
@@ -192,6 +219,33 @@ describe('SearchSource', () => {
192219 ],
193220 }
194221 ` ) ;
222+
223+ // calling twice gives the same result: no double-added filters
224+ expect ( searchSource . getFields ( RECURSE ) ) . toMatchInlineSnapshot ( `
225+ Object {
226+ "aggs": 5,
227+ "filter": Array [
228+ Object {
229+ "meta": Object {
230+ "alias": null,
231+ "disabled": false,
232+ "index": "d180cae0-60c3-11eb-8569-bd1f5ed24bc9",
233+ "negate": false,
234+ "params": Object {},
235+ },
236+ "query": Object {
237+ "range": Object {
238+ "@date": Object {
239+ "format": "strict_date_optional_time",
240+ "gte": "2016-01-27T18:11:05.010Z",
241+ "lte": "2021-01-27T18:11:05.010Z",
242+ },
243+ },
244+ },
245+ },
246+ ],
247+ }
248+ ` ) ;
195249 } ) ;
196250 } ) ;
197251
Original file line number Diff line number Diff line change @@ -206,10 +206,13 @@ export class SearchSource {
206206 }
207207 }
208208
209- // set filter to the array of non-function-type filters
210- this . setField ( 'filter' , thisFilter ) ;
209+ // add combined filters to the fields
210+ const thisFields = {
211+ ...this . fields ,
212+ filter : thisFilter ,
213+ } ;
211214
212- return { ...parentFields , ...this . fields } ;
215+ return { ...parentFields , ...thisFields } ;
213216 }
214217 }
215218 return { ...this . fields } ;
You can’t perform that action at this time.
0 commit comments