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

[Maps] Remove deprecated usage of indexPattern.title #143444

Merged
merged 4 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,17 @@ export class ESGeoGridSource extends AbstractESAggSource implements IMvtVectorSo
refreshToken: string,
hasLabels: boolean
): Promise<string> {
const indexPattern = await this.getIndexPattern();
const dataView = await this.getIndexPattern();
const searchSource = await this.makeSearchSource(searchFilters, 0);
searchSource.setField('aggs', this.getValueAggsDsl(indexPattern));
searchSource.setField('aggs', this.getValueAggsDsl(dataView));

const mvtUrlServicePath = getHttp().basePath.prepend(
`/${GIS_API_PATH}/${MVT_GETGRIDTILE_API_PATH}/{z}/{x}/{y}.pbf`
);

return `${mvtUrlServicePath}\
?geometryFieldName=${this._descriptor.geoField}\
&index=${indexPattern.title}\
&index=${dataView.getIndexPattern()}\
&gridPrecision=${this._getGeoGridPrecisionResolutionDelta()}\
&hasLabels=${hasLabels}\
&requestBody=${encodeMvtResponseBody(searchSource.getSearchRequestBody())}\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,9 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
}

async getSourceIndexList(): Promise<string[]> {
await this.getIndexPattern();
if (!(this.indexPattern && this.indexPattern.title)) {
return [];
}
const dataView = await this.getIndexPattern();
try {
const { success, matchingIndexes } = await getMatchingIndexes(this.indexPattern.title);
const { success, matchingIndexes } = await getMatchingIndexes(dataView.getIndexPattern());
return success ? matchingIndexes : [];
} catch (e) {
// Fail silently
Expand Down Expand Up @@ -497,11 +494,8 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
}

async _isDrawingIndex(): Promise<boolean> {
await this.getIndexPattern();
if (!(this.indexPattern && this.indexPattern.title)) {
return false;
}
const { success, isDrawingIndex } = await getIsDrawLayer(this.indexPattern.title);
const dataView = await this.getIndexPattern();
const { success, isDrawingIndex } = await getIsDrawLayer(dataView.getIndexPattern());
return success && isDrawingIndex;
}

Expand All @@ -511,8 +505,8 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
}

async getMaxResultWindow(): Promise<number> {
const indexPattern = await this.getIndexPattern();
const indexSettings = await loadIndexSettings(indexPattern.title);
const dataView = await this.getIndexPattern();
const indexSettings = await loadIndexSettings(dataView.getIndexPattern());
return indexSettings.maxResultWindow;
}

Expand Down Expand Up @@ -832,8 +826,8 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
refreshToken: string,
hasLabels: boolean
): Promise<string> {
const indexPattern = await this.getIndexPattern();
const indexSettings = await loadIndexSettings(indexPattern.title);
const dataView = await this.getIndexPattern();
const indexSettings = await loadIndexSettings(dataView.getIndexPattern());

const searchSource = await this.makeSearchSource(searchFilters, indexSettings.maxResultWindow);
// searchSource calls dataView.getComputedFields to seed docvalueFields
Expand All @@ -855,7 +849,7 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
return fieldName !== this._descriptor.geoField;
})
.map((fieldName) => {
const field = indexPattern.fields.getByName(fieldName);
const field = dataView.fields.getByName(fieldName);
return field && field.type === 'date'
? {
field: fieldName,
Expand All @@ -876,7 +870,7 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource

return `${mvtUrlServicePath}\
?geometryFieldName=${this._descriptor.geoField}\
&index=${indexPattern.title}\
&index=${dataView.getIndexPattern()}\
&hasLabels=${hasLabels}\
&requestBody=${encodeMvtResponseBody(requestBody)}\
&token=${refreshToken}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class TopHitsForm extends Component<Props, State> {

async loadIndexSettings() {
try {
const indexPattern = await getIndexPatternService().get(this.props.indexPatternId);
const { maxInnerResultWindow } = await loadIndexSettings(indexPattern!.title);
const dataView = await getIndexPatternService().get(this.props.indexPatternId);
const { maxInnerResultWindow } = await loadIndexSettings(dataView.getIndexPattern());
if (this._isMounted) {
this.setState({ maxInnerResultWindow });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export class ScalingForm extends Component<Props, State> {

async loadIndexSettings() {
try {
const indexPattern = await getIndexPatternService().get(this.props.indexPatternId);
const { maxResultWindow } = await loadIndexSettings(indexPattern!.title);
const dataView = await getIndexPatternService().get(this.props.indexPatternId);
const { maxResultWindow } = await loadIndexSettings(dataView.getIndexPattern());
if (this._isMounted) {
this.setState({ maxResultWindow: maxResultWindow.toLocaleString() });
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getIsCloud = () => isCloudEnabled;

export const getIndexNameFormComponent = () => pluginsStart.fileUpload.IndexNameFormComponent;
export const getFileUploadComponent = () => pluginsStart.fileUpload.FileUploadComponent;
export const getIndexPatternService = () => pluginsStart.data.indexPatterns;
export const getIndexPatternService = () => pluginsStart.data.dataViews;
export const getAutocompleteService = () => pluginsStart.unifiedSearch.autocomplete;
export const getInspector = () => pluginsStart.inspector;
export const getFileUpload = () => pluginsStart.fileUpload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const visualizeGeoFieldAction = createAction<VisualizeFieldContext>({
});

const getMapsLink = async (context: VisualizeFieldContext) => {
const indexPattern = await getIndexPatternService().get(context.dataViewSpec.id!);
const dataView = await getIndexPatternService().get(context.dataViewSpec.id!);
// create initial layer descriptor
const hasTooltips =
context?.contextualFields?.length && context?.contextualFields[0] !== '_source';
Expand All @@ -76,7 +76,7 @@ const getMapsLink = async (context: VisualizeFieldContext) => {
id: uuid(),
type: SOURCE_TYPES.ES_SEARCH,
tooltipProperties: hasTooltips ? context.contextualFields : [],
label: indexPattern.title,
label: dataView.getIndexPattern(),
indexPatternId: context.dataViewSpec.id,
geoField: context.fieldName,
scalingType: SCALING_TYPES.MVT,
Expand Down