mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
This commit is contained in:
parent
6ef31d3531
commit
e161dc724b
2 changed files with 31 additions and 26 deletions
|
@ -89,28 +89,22 @@ export function createIndexPatternsApiClient($http, basePath) {
|
|||
params,
|
||||
} = options;
|
||||
|
||||
const url = getUrl(['_fields_for_wildcard'], {
|
||||
pattern,
|
||||
meta_fields: metaFields,
|
||||
});
|
||||
let url;
|
||||
|
||||
// Fetch fields normally, and then if the index pattern is a specific type,
|
||||
// pass the retrieved field information to the type-specific fields API for
|
||||
// further processing
|
||||
return request('GET', url).then(resp => {
|
||||
if(type) {
|
||||
const typeUrl = getUrl([type, '_fields_for_wildcard'], {
|
||||
pattern,
|
||||
fields: resp.fields,
|
||||
meta_fields: metaFields,
|
||||
params: JSON.stringify(params),
|
||||
});
|
||||
if(type) {
|
||||
url = getUrl([type, '_fields_for_wildcard'], {
|
||||
pattern,
|
||||
meta_fields: metaFields,
|
||||
params: JSON.stringify(params),
|
||||
});
|
||||
} else {
|
||||
url = getUrl(['_fields_for_wildcard'], {
|
||||
pattern,
|
||||
meta_fields: metaFields,
|
||||
});
|
||||
}
|
||||
|
||||
return request('GET', typeUrl).then(typeResp => typeResp.fields);
|
||||
} else {
|
||||
return resp.fields;
|
||||
}
|
||||
});
|
||||
return request('GET', url).then(resp => resp.fields);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { wrapEsError, wrapUnknownError } from '../../lib/error_wrappers';
|
|||
import { licensePreRoutingFactory } from'../../lib/license_pre_routing_factory';
|
||||
import indexBy from 'lodash/collection/indexBy';
|
||||
import { getCapabilitiesForRollupIndices } from '../../lib/map_capabilities';
|
||||
import querystring from 'querystring';
|
||||
|
||||
/**
|
||||
* Get list of fields for rollup index pattern, in the format of regular index pattern fields
|
||||
|
@ -25,26 +26,36 @@ export function registerFieldsForWildcardRoute(server) {
|
|||
pre: [ licensePreRouting ],
|
||||
validate: {
|
||||
query: Joi.object().keys({
|
||||
pattern: Joi.string(),
|
||||
pattern: Joi.string().required(),
|
||||
meta_fields: Joi.array().items(Joi.string()).default([]),
|
||||
fields: Joi.array(),
|
||||
params: Joi.object().keys({
|
||||
rollup_index: Joi.string().required(),
|
||||
}).default({})
|
||||
}).required()
|
||||
}).default()
|
||||
}
|
||||
},
|
||||
handler: async (request) => {
|
||||
const {
|
||||
pattern,
|
||||
meta_fields: metaFields,
|
||||
fields,
|
||||
params,
|
||||
} = request.query;
|
||||
|
||||
const rollupIndex = params.rollup_index;
|
||||
const callWithRequest = callWithRequestFactory(server, request);
|
||||
// Format call to standard index pattern `fields for wildcard`
|
||||
const standardRequest = {
|
||||
url: `/api/index_patterns/_fields_for_wildcard?${querystring.stringify({ pattern, meta_fields: metaFields })}`,
|
||||
method: 'GET',
|
||||
headers: request.headers,
|
||||
};
|
||||
|
||||
try {
|
||||
// Make call and use field information from response
|
||||
const standardResponse = await server.inject(standardRequest);
|
||||
const fields = standardResponse.result && standardResponse.result.fields;
|
||||
|
||||
const rollupIndex = params.rollup_index;
|
||||
const callWithRequest = callWithRequestFactory(server, request);
|
||||
|
||||
const rollupFields = [];
|
||||
const rollupFieldNames = [];
|
||||
const fieldsFromFieldCapsApi = indexBy(fields, 'name');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue