Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update aggregation config #3974

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add satisfaction survey link to help menu ([#3676] (https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3676))
- [Vis Builder] Add persistence to visualizations inner state ([#3751](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3751))
- [Table Visualization] Move format table, consolidate types and add unit tests ([#3397](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3397))
- [Data] Add geo_shape type field support in geo_tile and geo_hash aggregation ([#3974](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3974))

### 🐛 Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/aggs/buckets/geo_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const getGeoHashBucketAgg = () =>
{
name: 'field',
type: 'field',
filterFieldTypes: OSD_FIELD_TYPES.GEO_POINT,
filterFieldTypes: [OSD_FIELD_TYPES.GEO_POINT, OSD_FIELD_TYPES.GEO_SHAPE],
},
{
name: 'autoPrecision',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/aggs/buckets/geo_tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const getGeoTitleBucketAgg = () =>
{
name: 'field',
type: 'field',
filterFieldTypes: OSD_FIELD_TYPES.GEO_POINT,
filterFieldTypes: [OSD_FIELD_TYPES.GEO_POINT, OSD_FIELD_TYPES.GEO_SHAPE],
},
{
name: 'useGeocentroid',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const buckets = {
[BUCKET_TYPES.FILTERS]: {
filters: controls.FiltersParamEditor,
},
[BUCKET_TYPES.GEOTILE_GRID]: {
useGeocentroid: controls.UseGeocentroidParamEditor,
},
[BUCKET_TYPES.GEOHASH_GRID]: {
autoPrecision: controls.AutoPrecisionParamEditor,
precision: controls.PrecisionParamEditor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,57 @@
* under the License.
*/

import React from 'react';
import { EuiSwitch, EuiFormRow } from '@elastic/eui';
import React, { useState, useEffect } from 'react';
import { EuiSwitch, EuiFormRow, EuiToolTip } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { AggParamEditorProps } from '../agg_param_props';
import { OSD_FIELD_TYPES } from '../../../../../plugins/data/common';

function UseGeocentroidParamEditor({ agg, value = false, setValue }: AggParamEditorProps<boolean>) {
const [disabled, setDisabled] = useState(false);

function UseGeocentroidParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) {
const label = i18n.translate('visDefaultEditor.controls.placeMarkersOffGridLabel', {
defaultMessage: 'Place markers off grid (use geocentroid)',
});

const tooltipLabel = i18n.translate(
'visDefaultEditor.controls.placeMarkersOffGridLabelUnsupport',
{
defaultMessage: 'Currently geo_shape type field does not support centroid aggregation.',
}
);

useEffect(() => {
// geo_shape type field does not support centroid aggregation
if (agg?.params?.field?.type === OSD_FIELD_TYPES.GEO_SHAPE) {
setDisabled(true);
setValue(false);
} else {
setDisabled(false);
}
}, [agg, setValue]);

return (
<EuiFormRow display={'rowCompressed'}>
<EuiSwitch
compressed={true}
label={label}
checked={value}
onChange={(ev) => setValue(ev.target.checked)}
/>
{disabled ? (
<EuiToolTip content={tooltipLabel}>
<EuiSwitch
compressed={true}
disabled={true}
label={label}
checked={value}
onChange={(ev) => setValue(ev.target.checked)}
/>
</EuiToolTip>
) : (
<EuiSwitch
compressed={true}
disabled={false}
label={label}
checked={value}
onChange={(ev) => setValue(ev.target.checked)}
/>
)}
</EuiFormRow>
);
}
Expand Down