Skip to content

Commit

Permalink
[savedObjects] add experimental filter definition syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Apr 3, 2018
1 parent a4155e4 commit 8ae2587
Show file tree
Hide file tree
Showing 18 changed files with 960 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/dev/jest/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
roots: [
'<rootDir>/src/ui',
'<rootDir>/src/core_plugins',
'<rootDir>/src/server',
'<rootDir>/packages',
],
collectCoverageFrom: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ describe('SavedObjectsClient', () => {
searchFields: ['foo'],
type: 'bar',
sortField: 'name',
sortOrder: 'desc'
sortOrder: 'desc',
experimentalFilter: null
};

await savedObjectsClient.find(relevantOpts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ describe('getSearchDsl', () => {
});

describe('passes control', () => {
it('passes (mappings, type, search, searchFields) to getQueryParams', () => {
it('passes (mappings, type, search, searchFields, experimentalFilter) to getQueryParams', () => {
const spy = sandbox.spy(queryParamsNS, 'getQueryParams');
const mappings = { type: { properties: {} } };
const opts = {
type: 'foo',
search: 'bar',
searchFields: ['baz']
searchFields: ['baz'],
experimentalFilter: null
};

getSearchDsl(mappings, opts);
Expand All @@ -45,6 +46,7 @@ describe('getSearchDsl', () => {
opts.type,
opts.search,
opts.searchFields,
opts.experimentalFilter
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SavedObjectsClient/experimentalFilter properly converts complex example 1`] = `
Object {
"bool": Object {
"must": Array [
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.stars": Object {
"gt": 3,
"gte": undefined,
"lt": undefined,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.stars": Object {
"gt": 3,
"gte": undefined,
"lt": undefined,
"lte": undefined,
},
},
},
],
},
},
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.followers": Object {
"gt": undefined,
"gte": undefined,
"lt": undefined,
"lte": 5,
},
},
},
Object {
"range": Object {
"dashboard.followers": Object {
"gt": undefined,
"gte": undefined,
"lt": undefined,
"lte": 5,
},
},
},
],
},
},
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.created": Object {
"gt": undefined,
"gte": 2018-03-02T07:00:00.000Z,
"lt": 2018-03-03T07:00:00.000Z,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.created": Object {
"gt": undefined,
"gte": 2018-03-02T07:00:00.000Z,
"lt": 2018-03-03T07:00:00.000Z,
"lte": undefined,
},
},
},
],
},
},
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.created": Object {
"gt": undefined,
"gte": 2018-02-25T07:00:00.000Z,
"lt": 2018-03-01T07:00:00.000Z,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.created": Object {
"gt": undefined,
"gte": 2018-02-25T07:00:00.000Z,
"lt": 2018-03-01T07:00:00.000Z,
"lte": undefined,
},
},
},
],
},
},
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.created": Object {
"gt": undefined,
"gte": undefined,
"lt": 2012-01-01T07:00:00.000Z,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.created": Object {
"gt": undefined,
"gte": undefined,
"lt": 2012-01-01T07:00:00.000Z,
"lte": undefined,
},
},
},
],
},
},
Object {
"multi_match": Object {
"fields": undefined,
"query": "dashboard",
"type": "phrase",
},
},
Object {
"multi_match": Object {
"fields": Array [
"visualize.active",
"dashboard.active",
],
"query": true,
"type": "phrase",
},
},
Object {
"bool": Object {
"must": Array [],
"must_not": Array [],
"should": Array [
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.created": Object {
"gt": undefined,
"gte": 2018-03-02T07:00:00.000Z,
"lt": 2018-03-03T07:00:00.000Z,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.created": Object {
"gt": undefined,
"gte": 2018-03-02T07:00:00.000Z,
"lt": 2018-03-03T07:00:00.000Z,
"lte": undefined,
},
},
},
],
},
},
Object {
"bool": Object {
"should": Array [
Object {
"range": Object {
"visualize.created": Object {
"gt": undefined,
"gte": 2018-03-01T07:00:00.000Z,
"lt": 2018-03-02T07:00:00.000Z,
"lte": undefined,
},
},
},
Object {
"range": Object {
"dashboard.created": Object {
"gt": undefined,
"gte": 2018-03-01T07:00:00.000Z,
"lt": 2018-03-02T07:00:00.000Z,
"lte": undefined,
},
},
},
],
},
},
],
},
},
],
"must_not": Array [
Object {
"multi_match": Object {
"fields": Array [
"visualize.status",
"dashboard.status",
],
"query": "open",
"type": "phrase",
},
},
Object {
"multi_match": Object {
"fields": Array [
"visualize.owner",
"dashboard.owner",
],
"query": "dewey",
"type": "phrase",
},
},
Object {
"bool": Object {
"must": Array [],
"must_not": Array [],
"should": Array [
Object {
"multi_match": Object {
"fields": Array [
"visualize.tag",
"dashboard.tag",
],
"query": "finance",
"type": "phrase",
},
},
Object {
"multi_match": Object {
"fields": Array [
"visualize.tag",
"dashboard.tag",
],
"query": "eng",
"type": "phrase",
},
},
Object {
"multi_match": Object {
"fields": Array [
"visualize.tag",
"dashboard.tag",
],
"query": "ga",
"type": "phrase",
},
},
],
},
},
],
"should": Array [],
},
}
`;
Loading

0 comments on commit 8ae2587

Please sign in to comment.