forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate filter bar to React, EUI, and Typescript (elastic#25563)
Rewrites the filter bar in React, EUI, and Typescript. Updates the look and feel of the filter bar and makes it consistent with the rest of K7.
- Loading branch information
Showing
136 changed files
with
4,131 additions
and
3,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# kbn-es-query | ||
|
||
This module is responsible for generating Elasticsearch queries for Kibana. See explanations below for each of the subdirectories. | ||
|
||
## es_query | ||
|
||
This folder contains the code that combines Lucene/KQL queries and filters into an Elasticsearch query. | ||
|
||
```javascript | ||
buildEsQuery(indexPattern, queries, filters, config) | ||
``` | ||
|
||
Generates the Elasticsearch query DSL from combining the queries and filters provided. | ||
|
||
```javascript | ||
buildQueryFromFilters(filters, indexPattern) | ||
``` | ||
|
||
Generates the Elasticsearch query DSL from the given filters. | ||
|
||
```javascript | ||
luceneStringToDsl(query) | ||
``` | ||
|
||
Generates the Elasticsearch query DSL from the given Lucene query. | ||
|
||
```javascript | ||
migrateFilter(filter, indexPattern) | ||
``` | ||
|
||
Migrates a filter from a previous version of Elasticsearch to the current version. | ||
|
||
```javascript | ||
decorateQuery(query, queryStringOptions) | ||
``` | ||
|
||
Decorates an Elasticsearch query_string query with the given options. | ||
|
||
## filters | ||
|
||
This folder contains the code related to Kibana Filter objects, including their definitions, and helper functions to create them. Filters in Kibana always contain a `meta` property which describes which `index` the filter corresponds to, as well as additional data about the specific filter. | ||
|
||
The object that is created by each of the following functions corresponds to a Filter object in the `lib` directory (e.g. `PhraseFilter`, `RangeFilter`, etc.) | ||
|
||
```javascript | ||
buildExistsFilter(field, indexPattern) | ||
``` | ||
|
||
Creates a filter (`ExistsFilter`) where the given field exists. | ||
|
||
```javascript | ||
buildPhraseFilter(field, value, indexPattern) | ||
``` | ||
|
||
Creates an filter (`PhraseFilter`) where the given field matches the given value. | ||
|
||
```javascript | ||
buildPhrasesFilter(field, params, indexPattern) | ||
``` | ||
|
||
Creates a filter (`PhrasesFilter`) where the given field matches one or more of the given values. `params` should be an array of values. | ||
|
||
```javascript | ||
buildQueryFilter(query, index) | ||
``` | ||
|
||
Creates a filter (`CustomFilter`) corresponding to a raw Elasticsearch query DSL object. | ||
|
||
```javascript | ||
buildRangeFilter(field, params, indexPattern) | ||
``` | ||
|
||
Creates a filter (`RangeFilter`) where the value for the given field is in the given range. `params` should contain `lt`, `lte`, `gt`, and/or `gte`. | ||
|
||
## kuery | ||
|
||
This folder contains the code corresponding to generating Elasticsearch queries using the Kibana query language. | ||
|
||
It also contains code corresponding to the original implementation of Kuery (released in 6.0) which should be removed at some point (see legacy_kuery.js, legacy_kuery.peg). | ||
|
||
In general, you will only need to worry about the following functions from the `ast` folder: | ||
|
||
```javascript | ||
fromExpression(expression) | ||
``` | ||
|
||
Generates an abstract syntax tree corresponding to the raw Kibana query `expression`. | ||
|
||
```javascript | ||
toElasticsearchQuery(node, indexPattern) | ||
``` | ||
|
||
Takes an abstract syntax tree (generated from the previous method) and generates the Elasticsearch query DSL using the given `indexPattern`. Note that if no `indexPattern` is provided, then an Elasticsearch query DSL will still be generated, ignoring things like the index pattern scripted fields, field types, etc. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,15 @@ | |
"license": "Apache-2.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "babel src --out-dir target", | ||
"build": "tsc && babel src --out-dir target", | ||
"kbn:bootstrap": "yarn build --quiet", | ||
"kbn:watch": "yarn build --watch" | ||
}, | ||
}, | ||
"dependencies": { | ||
"lodash": "npm:@elastic/[email protected]" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^3.0.3", | ||
"@kbn/babel-preset": "1.0.0", | ||
"babel-cli": "^6.26.0", | ||
"expect.js": "0.3.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Filter, FilterMeta } from './meta_filter'; | ||
|
||
export type ExistsFilterMeta = FilterMeta; | ||
|
||
export type ExistsFilter = Filter & { | ||
meta: ExistsFilterMeta; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/kbn-es-query/src/filters/lib/geo_polygon_filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { Filter, FilterMeta, LatLon } from './meta_filter'; | ||
|
||
export type GeoPolygonFilterMeta = FilterMeta & { | ||
params: { | ||
points: LatLon[]; | ||
}; | ||
}; | ||
|
||
export type GeoPolygonFilter = Filter & { | ||
meta: GeoPolygonFilterMeta; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
// The interface the other filters extend | ||
export * from './meta_filter'; | ||
|
||
// The actual filter types | ||
import { CustomFilter } from './custom_filter'; | ||
import { ExistsFilter } from './exists_filter'; | ||
import { GeoBoundingBoxFilter } from './geo_bounding_box_filter'; | ||
import { GeoPolygonFilter } from './geo_polygon_filter'; | ||
import { PhraseFilter } from './phrase_filter'; | ||
import { PhrasesFilter } from './phrases_filter'; | ||
import { QueryStringFilter } from './query_string_filter'; | ||
import { RangeFilter } from './range_filter'; | ||
export { | ||
CustomFilter, | ||
ExistsFilter, | ||
GeoBoundingBoxFilter, | ||
GeoPolygonFilter, | ||
PhraseFilter, | ||
PhrasesFilter, | ||
QueryStringFilter, | ||
RangeFilter, | ||
}; | ||
|
||
// Any filter associated with a field (used in the filter bar/editor) | ||
export type FieldFilter = | ||
| ExistsFilter | ||
| GeoBoundingBoxFilter | ||
| GeoPolygonFilter | ||
| PhraseFilter | ||
| PhrasesFilter | ||
| RangeFilter; |
Oops, something went wrong.